Kill a named process in win2K not spawned by python

P

PoulsenL

Can someone give me a clue how to rewrite this kludgy workaround in python?

import os
from win32pdhutil import *
pid = FindPerformanceAttributesByName("WINWORD")[0]
os.system("C:\CMDUtils\kill " + str(pid))

Thanks,

Loren Poulsen
 
S

Syver Enstad

Can someone give me a clue how to rewrite this kludgy workaround in
python?


import os
from win32pdhutil import *
pid = FindPerformanceAttributesByName("WINWORD")[0]

import win32process, win32api, win32con
handle = win32api.OpenProcess(win32con.SYNCHRONIZE|win32con.PROCESS_QUERY_INFORMATION|win32con.PROCESS_TERMINATE, 1, pid)
win32api.TerminateProcess(handle, 1) # exit status
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top