Doing a ps in windows.. (Is application XYZZY running?)

Douglas Alan nessus at mit.edu
Fri Jun 21 18:14:44 EDT 2002


I've been trying to follow your recommendation as you wrote below, but
it isn't working for me.  For instance, if I run the following code:

    while 1:
       junk, instances = win32pdh.EnumObjectItems(
          None, None, "process", win32pdh.PERF_DETAIL_WIZARD)
       print len(instances), instances
       if "winvrut2" in instances: sleep(1)
       else: break

The loop never terminates, and the string printed out never changes,
even after the process "winvrut2" terminates, and many other processes
come and go.  It seems that the list of processes is being cached, and
then EnumObjectItems just returns the value from the cache.  How do I
flush the cache?

This is under Windows2000, and ActivePython-2.1.

|>oug


Wolfgang Strobl <ws at mystrobl.de> writes:

> Mon, 25 Mar 2002 20:54:19 GMT, Andrew Markebo
> <flognat at flognat.myip.org>:
> 
> >*blush* yeah I know.. not really.. here, only almost :-)
> >
> >I have the windows-compiled python 2.2, and I would like to see if
> >Opera or Netscape is running on my computer (poor sod, running Win2k,
> >XP or 98).. How do I do this, I suppose I could use something in the
> >win32api, but what is something.. :-) ??
> >
> >On unix I do "ps -ef | grep netscape" ;-)
> 
> On Windows, I do 
> 
> >>> import win32pdh
> >>> junk, instances = win32pdh.EnumObjectItems(None,None,"process",
> ...     win32pdh.PERF_DETAIL_WIZARD)
> >>> "python" in instances
> 1
> >>> "netscape" in instances
> 0
> >>>
> 
> (straight from an example in the win32pdh documentation)
> 
> -- 
> Wir danken für die Beachtung aller Sicherheitsbestimmungen




More information about the Python-list mailing list