14-08-14, 10:06 AM
Private Sub KillProcess (processName as String )
For Each currentProcess As Process In System.Diagnostics.Process.GetProcessesByName("processName ")
Try
currentProcess.Kill()
' possibly with a timeout
currentProcess.WaitForExit()
Catch winException As Win32Exception ' process was terminating or can't be terminated ...... deal with it
' do something
Catch invalidException As InvalidOperationException ' process has already exited ...... might be able to let this one go
Exit sub
End Try
Next
End Sub
For Each currentProcess As Process In System.Diagnostics.Process.GetProcessesByName("processName ")
Try
currentProcess.Kill()
' possibly with a timeout
currentProcess.WaitForExit()
Catch winException As Win32Exception ' process was terminating or can't be terminated ...... deal with it
' do something
Catch invalidException As InvalidOperationException ' process has already exited ...... might be able to let this one go
Exit sub
End Try
Next
End Sub

