We help IT Professionals succeed at work.

Check out our new AWS podcast with Certified Expert, Phil Phillips! Listen to "How to Execute a Seamless AWS Migration" on EE or on your favorite podcast platform. Listen Now

x

Process Running ?

gnow
gnow asked
on
Medium Priority
212 Views
Last Modified: 2010-04-02
Is there a function in NT which returns the ProcessId
of a Process, if I only know the process-name ? What
am I looking for is something like this:

pid = processId ( "NameOfTheProcess" );
Comment
Watch Question

Commented:
Processes don't have names.  What information do you have about the process?  Did your program start the process?  Do you know anything about windows the process creates, if any?
jkr
CERTIFIED EXPERT
Top Expert 2012

Commented:
You could use the functions provided with 'psapi.dll' to achieve this - sorry, but as i'm at home now, you'll have to wait for an example 'til tomorrow ;-)
If you have the name of the window caption, or it's class name, you can use FindWindow, and then GetWindowThreadProcessID

Author

Commented:
That's my problem. The process are started in a command prompt and started during startup of NT.

My goal is to generate a watchdog-process, which is checking several processes
from time to time if they are still running. If not, it should restart these processes. Due
to I don't want any interprocess-communication I need something indepandent from
the other processes.

It could be that my idea is wrong and I have to go a different way. Has anybody
expirience in doing this ? Is it better to start the processes as a service and then
have a "watchdog-service" check the other services ?

Commented:
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION

Commented:
Opps.  Missed one thing.  To enumerate 16 bit processes in NT you must use VDMEnumTaskWOWEx().  This will save you from having to use GetModuleFilenameEx() as the callback routine will be passed the executable's path and file name.

Look up article Q175030 in the MS knowledgebase.  It describes the details.
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a sample view!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.