[python-win32] fast test if (unknown) process is running ? Why not use Autoit ?
Stef Mientki
stef.mientki at gmail.com
Fri Aug 6 21:10:02 CEST 2010
thanks,
On 06-08-2010 15:37, sharpblade wrote:
> You are not using the WMI efficiently. You iterate over every process to test if only one is
> there, when you can use WMI like so:
>
> >>> import wmi
> >>> x = wmi.WMI()
> >>> x.query("SELECT * FROM Win32_Process WHERE Name = 'xchat.exe'")
> [<_wmi_object: \\TOM-PC\root\cimv2:Win32_Process.Handle="7052">]
> >>> def test():
> t1 = time.time()
> x.query("SELECT * FROM Win32_Process WHERE Name = 'xchat.exe'")
> print time.time()-t1
>
> >>> import time
> >>> test()
> 0.0829999446869
> >>>
>
but that looks quit more complicated than psutils,
besides that I believe that psutils is platform independant.
cheers,
Stef
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-win32/attachments/20100806/4611a338/attachment-0001.html>
More information about the python-win32
mailing list