Trouble killing a process on windows

Thomas Nelson thn at mail.utexas.edu
Sat Jun 2 12:27:05 EDT 2007


Hi, I'd like to start a program, run it for a while, then terminate
it.  I can do this on linux, but I'm new to working with windows.
Here's my script:

from subprocess import Popen
from time import sleep
import win32api
war3game = Popen(["C:\Program Files\Warcraft III\Frozen Throne.exe"])
sleep(30)
print "slept for 30"
print win32api.TerminateProcess(int(war3game._handle),-1)
#print
ctypes.windll.kernel32.TerminateProcess(int(war3game._handle),-1)
print "terminated process"

Here's the output:
slept for 30
Traceback (most recent call last):
  File "C:\Python24\warcraft\runwar3.py", line 7, in ?
    print win32api.TerminateProcess(int(war3game._handle),-1)
error: (5, 'TerminateProcess', 'Access is denied.')

I'm logged in as adminstrator.  Does anyone know how to fix this
problem?
Thanks for your time,
Tom




More information about the Python-list mailing list