Ending program when a specific process stops

Capt_Ron

Active member
Joined
Apr 29, 2005
Messages
39
Programming Experience
1-3
I have a program that starts another program based on certain criteria.
I would like this program to continue to run until the other program closes.

How can I sense that the other program closes?

Thank you.

Ron.
 
Well, maybe this is not the real thing you need there. It's simple, but I hope you'll find it useful! ... let me know if you need additionally help ... Cheers :)


VB.NET:
Private[/color][/size][size=2][color=#0000ff]Sub[/color][/size][size=2] Button1_Click([/size][size=2][color=#0000ff]ByVal[/color][/size][size=2] sender [/size][size=2][color=#0000ff]As[/color][/size][size=2] System.Object, _[/size]
[size=2][color=#0000ff]ByVal[/color][/size][size=2] e [/size][size=2][color=#0000ff]As[/color][/size][size=2] System.EventArgs) [/size][size=2][color=#0000ff]Handles[/color][/size][size=2] Button1.Click
[/size][size=2][color=#0000ff]Dim[/color][/size][size=2] myProcess [/size][size=2][color=#0000ff]As[/color][/size][size=2] System.Diagnostics.Process = myProcess.Start("notepad")
 
myProcess.WaitForExit()
 
myProcess.Start("calc.exe")
 
[/size][size=2][color=#0000ff]End[/color][/size][size=2][color=#0000ff]Sub

first it will run the notepad and wait till you close the same and then start new process ...
 
Last edited:
Can we know whether a program (in this case 'notepad') has been closed or not... like:

if isClosed("notepad.exe") then
'do something
end if
 
ayozzhero said:
Can we know whether a program (in this case 'notepad') has been closed or not... like:

if isClosed("notepad.exe") then
'do something
end if
It's not quite as simple as that but you can use the Process class to determine whether a process with a particular name or ID is running. Check VS or VB help for the Process class for all the details.
 
Back
Top