How to obtain the PID from the command line

G

Guest

I have a dozen of batch files that execute every 5 minutes on a W2K server
(scheduled tasks).

Unfortunately, every 5 minutes a CMD.EXE process remains forever in the
Processes list (in the Windows Task Manager), which means that one of these
batch programs is blocked or not exiting at all. After 8 or 9 hours the
system is stuck and I need to kill them myself by hand!!!

I need to obtain the PID in which each batch program runs and log it into a
file so I can trace down which program is the one unable to close down.

Does someone know how to obtain the PID from the command line, so I will
change my programs and locate the wrong one?

Thank you a lot.

Stefano Gatto
Geneva, Switzerland
 
G

Guest

Jimmy,

Thanks for the web address, it contains many useful info and utilities I
might use, but not what I am looking for, although it may seem a basic
need... If I remember well from my UNIX years this was quite a basic function
to get the PID of the current command interpreter window (which is cmd.exe in
W2K).

Do you know of another web site like that I can search for this?

Thanks again and have a nice day.

Stefano
 
G

Guest

Thank you very much Rick.

But how does the batch file know which one is its process id? In particular
when many cmd.exe are running at the same time... What I need is just the PID
of the process hosting the running batch file, not the others.

Have a nice day.

Stefano
 
R

Rick

Probably the easiest way to find this info is to monitor the batch files,
and use something like Process Monitor (referenced earlier in this
thread) to see which instance is hanging up. If you expand the
display in Process Monitor and select 'handles' instead of DLLs for
the lower pane, it should be fairly easy to figure out.
 
G

Guest

Many, many thanks Rick,

This will help a lot. It is actually a necessary tool that distinguishes
between processes having the same "image name" in the Task Manager. Otherwise
there is no way to distinguish among them on that window.

Have a nice day.

Stefano
 

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

Top