469,645 Members | 1,120 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,645 developers. It's quick & easy.

Getting PID for process

Let's say I have a simple script on Windows NT. I would like for that
script to find its own PID once it's started and store that as a value
within the script. Also, down the road I'd like to kill that process by
its PID. How is this done?

Thanks,

Harlin Seritt

Jul 19 '05 #1
2 7389
try:

import os

myPID = os.getpid()

So you can kill it at a later date, it would be worth writing that out
to a file somewhere - C:\temp? I'm sure you can get a kill command for
Win32.

HTH

J

Harlin Seritt wrote:
Let's say I have a simple script on Windows NT. I would like for that
script to find its own PID once it's started and store that as a value
within the script. Also, down the road I'd like to kill that process by
its PID. How is this done?

Thanks,

Harlin Seritt


Jul 19 '05 #2
On XP/2003 at least,
os.system('taskkill /pid le <pid>') will do.

Jul 19 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Srinivas | last post: by
33 posts views Thread by JamesB | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.