[python-win32] How can I check that a process is already running ?

Bob Gailer bgailer at alum.rpi.edu
Tue Jun 3 09:59:27 EDT 2003


REVISE THAT TO NT4 TERMINAL SERVICES.

At 01:31 AM 6/3/2003 +0100, CPH wrote:
>I want to check to see if a process called "openoffice" is already
>running, how can I do this using python ?

At least on NT4 this works. I get various and unpredictable responses on 
Win 2K.:

cmd = os.popen('query process')
x = cmd.readlines()
for y in x:
   p = y.find('openoffice')
   if p >= 0: # process running

If you want the one line version:

if ''.join(os.popen('query process').readlines()).find('openoffice') >= 0:

Bob Gailer
bgailer at alum.rpi.edu
303 442 2625




More information about the Python-win32 mailing list