• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

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

jameswhite1979

Senior member
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
 
no need for a loop:

If Diagnostics.Process.GetProcessesByName("notepad.exe").Length > 1 Then
'it is running
else
'it is not running
End If
 
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
 
Back
Top