Is it possible to kill a process on Windows from within Python?
I would think you could just use taskkill and the Python os.system()
import osos.system("taskkill /im make.exe")
Note: I would just note you might have to fully qualify the taskkill path. I am using a Linux box so I can't test...
Yes,You can do it
import osos.system("taskkill /f /im Your_Process_Name.exe")
- /f : Specifies that process(es) be forcefully terminated.
- /im (ImageName ): Specifies the image name of the process to beterminated.
- For more info regarding TaskKill
There is a nice cross-platform python utility psutil that exposes a kill() routine on a processes that can be listed with psutil.process_iter().
There is already an example in the other thread: https://stackoverflow.com/a/4230226/4571444