[Tutor] Windows Processes

Shitiz Bansal shitizb at yahoo.com
Sun Feb 29 18:20:10 EST 2004


Hi,
I need to check whether a particular process is running on my windows machine or not.
The code i am using is:
 
import win32pdh
processinfo,processes=win32pdh.EnumObjectItems(None,None,"Process",-1)
number=processes.count('process name')
if number==1:
    print 'ok'
else:
    print 'notok'

All i need to do is to find the number of times a particular process is running.
The code works fine but the trouble is that it takes around 15 seconds to complete.
Since i do not require everything the program is doing(I already have the process name so no need to enumerate all processes and the processinfo is not required) , is there a faster and more efficient way of doing this?
 
Shitiz


---------------------------------
Do you Yahoo!?
Get better spam protection with Yahoo! Mail
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/tutor/attachments/20040229/b078c39c/attachment-0001.html


More information about the Tutor mailing list