[python-win32] Maybe the wrong newsgroup to ask ?

Tim Roberts timr at probo.com
Wed Jan 27 20:07:57 CET 2010


Stef Mientki wrote:
>
> I'm trying to kill processes,
> I started myself with subprocess.popen,
> under windows XP, Python 2.6
>
> Why are the subprocess.Popen methods kill() and terminate () not working,
> while a simple suggestion from this newsgroup, shown below, works
> perfect ?
> ...
>
>     My_Process = subprocess.popen ( ...)
>     handle = win32api.OpenProcess(win32con.PROCESS_TERMINATE, 0,
> My_Process.PID)
>     try:
>       win32api.TerminateProcess(handle,0)
>       win32api.CloseHandle(handle)       
>     except:   #the process might already be closed by the user
>       pass

There shouldn't be any difference.  If you look at the code in
subprocess. it calls the same API.  The handle returned from
CreateProcess has all access rights, including PROCESS_TERMINATE.

Can you show us your original code?

-- 
Tim Roberts, timr at probo.com
Providenza & Boekelheide, Inc.



More information about the python-win32 mailing list