0

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.

2 Answers 2

3

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.

Sign up to request clarification or add additional context in comments.

Comments

2

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.