Quantcast
Channel: VBForums
Viewing all articles
Browse latest Browse all 42215

VS 2008 [RESOLVED] Check if a Process is Running or not

$
0
0
hi all,

I am trying to check if a process is running, if yes it should fire a messagebox saying it is or it isnt, i am using this code by Rohit Arora from this post
http://social.msdn.microsoft.com/For...f-fb9faed7f330

It fires the messagebox when process is running but not when the process is not running, can anyone please help me out here?

vb.net Code:
  1. Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
  2.         IsApplicationRunning("iexplore")
  3.     End Sub
  4.  
  5.     Private Sub IsApplicationRunning(ByVal ApplicationName As String)
  6.         'http://social.msdn.microsoft.com/Forums/et-EE/netfxbcl/thread/abb28d8c-c432-4be1-9b4f-fb9faed7f330
  7.         Dim Currentprocess() As Process = Process.GetProcessesByName(ApplicationName)
  8.         If Currentprocess.Length > 0 Then
  9.             For Each RunningProcess As Process In Currentprocess
  10.                 If RunningProcess.ProcessName = ApplicationName Then
  11.                     MessageBox.Show(ApplicationName & " is already running")
  12.                 End If
  13.             Next
  14.         End If
  15.         If Currentprocess.Length > 0 Then
  16.             For Each RunningProcess As Process In Currentprocess
  17.                 If Not RunningProcess.ProcessName = ApplicationName Then
  18.                     MessageBox.Show(ApplicationName & " is not running")
  19.                 End If
  20.             Next
  21.         End If
  22.     End Sub

Viewing all articles
Browse latest Browse all 42215

Trending Articles