danucalovj

Detect running process

Aug 9th, 2012
32
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 0.43 KB | None | 0 0
  1. Try
  2.     'create an array of Processes
  3.     Dim npProc() As Process
  4.  
  5.     'GetProcesses returns an array of processes that are running
  6.     npProc = Process.GetProcesses
  7.  
  8.     For Each proc As Process In npProc
  9.         'check the ProcessName to find Notepad
  10.         If proc.ProcessName.Equals("notepad") Then
  11.             MessageBox.Show("Notepad is running")
  12.             'stop the process that is currently running
  13.             proc.Kill()
  14.         End If
  15.     Next
  16.  
  17. Catch ex As Exception
  18.  
  19. End Try
Advertisement
Add Comment
Please, Sign In to add comment