Reputation: 1652
I've been trying to kill a process but all my options give me a Windows Access Denied Error.
I open the process(a python script) through test= subprocess.Popen([sys.executable, "testsc.py"])
and I want to kill that process.
So far, I've tried os.kill(pid, signal.SIGILL)
, os.kill(pid, 9)
, test.Terminate()
and simply test.kill()
. All of these give me the error.
I am using Python 2.7.1.4 on a Windows 7 x86 machine. I would appreciate the help! Thanks!
Upvotes: 9
Views: 14664
Reputation: 110
Okey, so i was having the same problem, that you have + having a problem with some annoying api i tought "Well, there is no chance i must install the updates, YES or YES", but no, i did the next.
Warning; Before starting doing the 7th step try to install python when you finish the 6th step, if still not working, try starting with the 7th step.
This worked for me.
Upvotes: 0
Reputation: 10740
A workaround if anyone interested - even as an admin I get access denied on some services when using os.kill
. however, this works:
import subprocess
subprocess.check_output("Taskkill /PID %d /F" % pid)
So if you don't care about being cross-platform and want a quick and dirty solution - try this instead.
Upvotes: 3
Reputation: 90742
Funnily enough, it means that access is denied. You don't have permission to kill the process. This could be due to your account level (a "guest" sort of account or an account restricted by group policy) or it could be due to UAC (admin on your own machine but not running as admin—not sure if Windows 7 allows non-elevated process killing, though I would have thought it would).
Upvotes: 0