Solved

Need to find HProcess for a console app so I can TerminateProcess()

Posted on 2000-05-11
1
202 Views
Last Modified: 2013-12-03
Hi,

I have some trouble with a CGI program hanging sometimes and want to have some way to find out the HProcess so I can have another application kill it if necessary.

Most likely since it is a console app, I doubt it would have a window handle so that makes this harder.  What I thought might work would be to have the troublesome application mark it's HProcess number in the registry and remove it upon successful completion.  I don't know how to get that number since that number generally comes from CreateProcess which is done by MicroSoft Internet Information Server.

Too bad it takes sooo long for the application to "die" on it's own otherwise this wouldn't be necessary.  IIS seems to own the instance of the application and prohibit the normal user's Task manager "End process".

I'm hoping that if I have another IIS-run program, it could terminate any/all rogue processes.  Hopefully this will be possible because I think this would make it to be in the same "context".

Thanks for your help!
MP
0
Comment
Question by:mikepj
1 Comment
 
LVL 15

Accepted Solution

by:
NickRepin earned 100 total points
ID: 2802602
If your program is a console stand-alone application (.exe), you may call GetCurrentProcessId() from inside it and then store the PID in the registry.
Another app may read this PID, OpenProcess(PID) to get the handle of the 1st process, and then TerminateProcess().
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

zlib is a free compression library (a DLL) on which the popular gzip utility is built.  In this article, we'll see how to use the zlib functions to compress and decompress data in memory; that is, without needing to use a temporary file.  We'll be c…
With most software applications trying to cater to multiple user needs nowadays, the focus is to make them as configurable as possible. For e.g., when creating Silverlight applications which will connect to WCF services, the service end point usuall…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

930 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now