rectangletangle
rectangletangle

Reputation: 52941

How would I go about killing a process/application?

I'd like to be able to kill various programs mid-run using python. How would I go about this?

Something like this:

module.end_process('chrome.exe') 

This little bit of code would shut down Google Chrome.

This is in Windows 7, BTW.

Upvotes: 0

Views: 496

Answers (2)

sateesh
sateesh

Reputation: 28683

You need to use Python Win32 Extensions to handle Win32 processes from Python. You can use the approach explained in this mail thread to find out handle of the executable (process) which you want to kill. You can then pass the obtained handle to method win32Process.TerminateProcess to kill the application.

Upvotes: 2

tMC
tMC

Reputation: 19325

http://docs.python.org/library/os.html#os.kill

os.kill()

Although, you have to have the PID to use os.kill()- I'm not sure how to find a PID from a proc name with windows.

Upvotes: 3

Related Questions