Extract PID (Process ID) of processes...

September 2, 2010 at 14:21:29
Specs: Windows XP, 3GB
I want to run a batch file to look foran EXCELprocess that may be in a hung state on a server. So far, I am working with PSLIST from the Sysinternals. I can run that and save to a txt file, and I may have a line like this:

Name Pid Pri Thd Hnd Priv CPU Time Elapsed Time
EXCEL 1436 8 4 269 11084 0:00:05.171 5:57:05.221

I know how to get that 1436 into a variable. And I suppose even if it were 936, no problem. My concern is that I presume it could be 5 digets. Maybe I should just start assuming up to 5 and pull it. But I thought I'd ask if anyone knows of a tool to specifically pull lthe PIDS if I know the name of the process. In this case I may have 4 EXCEL processes running, and one hung. If for example, it is over a certain length of time, I plan to kill it.

Any thoughts?

See More: Extract PID (Process ID) of processes...

Report •

September 2, 2010 at 14:48:56
Is there any reason you need the PID? TASKKILL doesn't require one, and I'm not sure what else you'd do with it.

Report •

September 3, 2010 at 11:03:08
If you'd like to pull the PID, you can use tasklist:

for /f "tokens= 1,2 delims= " %%a in ('tasklist ^| findstr /i excel.exe') do (
echo %%b

Report •

Related Solutions

Ask Question