Get the pid of a os.startfile(filename)

D

dcrespo

Hi to all,

How can I get the Process ID (PID) of an application started because of
os.startfile(filename)?

Or, better, How can I get the PID of a running program, suposing I know
the name of the running application?

Many thanks.

Daniel
 
D

Do Re Mi chel La Si Do

Hi !

With W2K or WXP :

tasklist /FI "IMAGENAME eq exename.exe"


And, with Python, how capture this information :

def findPID(exename):
import os
a = os.popen4('tasklist /FI "IMAGENAME eq '+exename+'"')
a[0].flush()
try:
info=a[1].readlines()[3].split()
except:
info=[exename,"NotFound"]
return (info[0],info[1])

soft,pid=findPID("pythonw.exe")
print soft,' --> ',pid



@-salutations

Michel Claveau
 
D

dcrespo

Hi! That works perfect!

But how I do it in a Win98? Does the win32all library have a standard
way to do it?

Thank you

Daniel
 

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,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top