To detext when a program is NOT running (VB.NET)

jameswhite1979

Senior member
Apr 15, 2005
367
0
0
Hi,

I am looking for a snippet of VB.net code that will search for a running program i.e. notepad.exe and keep checking to see when it is no longer is running. When it detects that it is no longer running continue the code. Example:

----------------------
loop start
is notepad.exe running? = YES/NO

If notepad is running loop back to 'loop start'

If notepad is NOT running continue with program

----------------------


TIA, James
 

WannaFly

Platinum Member
Jan 14, 2003
2,811
1
0
no need for a loop:

If Diagnostics.Process.GetProcessesByName("notepad.exe").Length > 1 Then
'it is running
else
'it is not running
End If
 

jameswhite1979

Senior member
Apr 15, 2005
367
0
0
I just changed it a little bit as if you include '.exe' it does not detect it correctly and added >=, so:

If Diagnostics.Process.GetProcessesByName("notepad").Length >= 1 Then
'it is running
MessageBox.Show("notepad IS running")
Else
'it is not running
MessageBox.Show("notepad is Not running")
End If

Many thanks it was driving me nuts!

J