Hey guys,
I have a question regarding my code.
I'm using VB 2008 and have created a project that uses the Windows built in 'cleanmgr' to clean out old files, and then another function runs on to search for spyware.
Each process is set into separate forms - when one completes it opens the next form and closes itself - or at least it should!
"desired process is form 1 opens form 2 (cleanmgr), then form 2 runs - and when complete exits and runs form 3, then 4 and so on"
What happens is form 1 runs the cleanmgr for form2 - but form 1 never closes, and form 2 never displays until the cleanmgr is completed which then displays form 3, then form 4, then form 2, then 3 and so!!
Here's my code:
Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim clnmgr As Process
clnmgr = Process.Start("cleanmgr", "/sagerun:10101")
clnmgr.WaitForExit(240000)
' if the process doesn't complete within
' 4 minutes, kill it
If Not clnmgr.HasExited Then
clnmgr.Kill()
End If
Form3.Show()
Me.Close()
Any ideas most welcome.
TIA
I have a question regarding my code.
I'm using VB 2008 and have created a project that uses the Windows built in 'cleanmgr' to clean out old files, and then another function runs on to search for spyware.
Each process is set into separate forms - when one completes it opens the next form and closes itself - or at least it should!
"desired process is form 1 opens form 2 (cleanmgr), then form 2 runs - and when complete exits and runs form 3, then 4 and so on"
What happens is form 1 runs the cleanmgr for form2 - but form 1 never closes, and form 2 never displays until the cleanmgr is completed which then displays form 3, then form 4, then form 2, then 3 and so!!
Here's my code:
Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim clnmgr As Process
clnmgr = Process.Start("cleanmgr", "/sagerun:10101")
clnmgr.WaitForExit(240000)
' if the process doesn't complete within
' 4 minutes, kill it
If Not clnmgr.HasExited Then
clnmgr.Kill()
End If
Form3.Show()
Me.Close()
Any ideas most welcome.
TIA