Check if process running then terminate if is?

  • Thread starter Thread starter Smokey Grindel
  • Start date Start date
S

Smokey Grindel

Is there anyway to check if an external process is running, then terminate
it if it is? my problem right now is in my installer the user might try to
upgrade while the program is running... I want to check if it is running,
notify them it is, then ask them if they want to terminate it or not...
thanks!
 
Smokey Grindel said:
Is there anyway to check if an external process is running, then terminate
it if it is? my problem right now is in my installer the user might try to
upgrade while the program is running... I want to check if it is running,
notify them it is, then ask them if they want to terminate it or not...
thanks!

There is a Kill method on the Process class.

There is a CloseMainWindow function on the Process class which is most
likely a better way to go, since it gives the process a chance to cleanup.
If the process is a runaway then Kill would be the "best" way to go.

Hope this helps
LLoyd SHeen
 
Is there anyway to check if an external process is running, then terminate
it if it is? my problem right now is in my installer the user might try to
upgrade while the program is running... I want to check if it is running,
notify them it is, then ask them if they want to terminate it or not...
thanks!

Smokey,
To terminate a process:

' Be careful not to add ".exe" extension to your process name
For Each myprocess As Process In Process.GetProcessesByName("process")
myprocess.Kill()
Next
 
Thanks both of you!

kimiraikkonen said:
Smokey,
To terminate a process:

' Be careful not to add ".exe" extension to your process name
For Each myprocess As Process In Process.GetProcessesByName("process")
myprocess.Kill()
Next
 
Back
Top