473,320 Members | 1,859 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Get the pid of a os.startfile(filename)

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

Nov 8 '05 #1
2 3365
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


Nov 8 '05 #2
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

Nov 9 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: lonelyplanet999 | last post by:
Hi, I'm a newbie to perl and is now studying about perl programming, I read some perl programming tutorials online (enter 'Perl tutorial' at google.com) and also find some sample perl scripts...
6
by: Timothy Smith | last post by:
hello i have a very odd issue with os.startfile() ok basicly my app works perfectly on every single other pc todate. i cannot recreate this issue on any system. so i've already ruled out any...
3
by: will.h.brown | last post by:
Hi! I'm new to Python and I need to call an executable file from my script. Is that possible, and if so, how? Thank you! whb
1
by: shing | last post by:
1. How would you make python open up windows programs? 2. How would you make python get data from a website, let's say, when google updates their main index page.
2
by: dazzler | last post by:
I need to open PDF file with my python application, and I'm using os.startfile(filename.pdf) command, I would need open command act 100% like clicking the file in the windows explorer python...
34
by: Alexnb | last post by:
Gerhard Häring wrote: No, it didn't work, but it gave me some interesting feedback when I ran it in the shell. Heres what it told me: Traceback (most recent call last): File...
1
by: Alexnb | last post by:
Okay, so I wrote some code of basically what I will be doing, only with exactly what I need for this part of the program but here you go: from Tkinter import* import os class myApp: def...
2
by: yqyq22 | last post by:
HI, i would like to know if there is a way to create a python script for automate mstsc.exe username and pwd credential, i mean i would create a script that first open mstsc.exe and in the same...
3
by: gaurav kashyap | last post by:
Dear all. On windows platform python 2.4,i can use os.startfile("filename") to execute a file on a new command prompt but on unix platform and python 2.3 what is the alternate for executing a...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.