Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Vista Newsgroups > Vista General

Vista - Process ids

Reply
 
Old 12-18-2008   #1 (permalink)
Steve Rainbird


 
 

Process ids

Is it possible to get the process id of a program that you have just run in
a bat file?

--
Steve


My System SpecsSystem Spec
Old 12-18-2008   #2 (permalink)
Chirag


 
 

Re: Process ids

If only one instance of that program is running, the following bat file
could prove useful to you to determine the PID of that process:

---
@echo off
set PID=
for /F "tokens=2 delims=," %%A in ('tasklist /nh /fo csv /fi "imagename eq
notepad.exe"') do set PID=%%A
echo pid=%PID%
---

Note that "for...do set PID=%%A" is in the same line (the post may
wrap-around). Replace notepad.exe with the executable name of the program
for which you want to find the process id.

- Chirag

PowerShow - View multiple PowerPoint slide shows simultaneously
http://officeone.mvps.org/powershow/powershow.html

"Steve Rainbird" <steve.nospam.rainbird@xxxxxx> wrote in message
news:6r0527Ff35j5U1@xxxxxx
Quote:

> Is it possible to get the process id of a program that you have just run
> in a bat file?
>
> --
> Steve
My System SpecsSystem Spec
Old 12-19-2008   #3 (permalink)
Steve Rainbird


 
 

Re: Process ids



"Chirag" <Chirag@xxxxxx> wrote in message
news:393DE370-70F0-4D0A-948E-E462A91360E6@xxxxxx
Quote:

> If only one instance of that program is running, the following bat file
> could prove useful to you to determine the PID of that process:
>
> ---
> @echo off
> set PID=
> for /F "tokens=2 delims=," %%A in ('tasklist /nh /fo csv /fi "imagename eq
> notepad.exe"') do set PID=%%A
> echo pid=%PID%
> ---
>
> Note that "for...do set PID=%%A" is in the same line (the post may
> wrap-around). Replace notepad.exe with the executable name of the program
> for which you want to find the process id.
>
> - Chirag
>
> PowerShow - View multiple PowerPoint slide shows simultaneously
> http://officeone.mvps.org/powershow/powershow.html
>
> "Steve Rainbird" <steve.nospam.rainbird@xxxxxx> wrote in
> message news:6r0527Ff35j5U1@xxxxxx
Quote:

>> Is it possible to get the process id of a program that you have just run
>> in a bat file?
>>
>> --
>> Steve
>
Chirag,

Thanks for that but the reason I want to know the pid is that there may be
many running.

I want the program to create a print file which contains its pid so that the
script can then print that file after it has finished.

--
Steve

My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
Failover Guest Cluster -- 'The process cannot access the file becauseit is being used by another process.' Virtual Server
Process count wrong when only one process matches criteria PowerShell
get-process & stop-process by owner PowerShell
Process dwm.exe Vista installation & setup
Bug? Shouldn't Stop-Process automatically match Id if object is a process? PowerShell


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46