Solved

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

Posted on 2000-05-11
1
200 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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

After several hours of googling I could not gather any information on this topic. There are several ways of controlling the USB port connected to any storage device. The best example of that is by changing the registry value of "HKEY_LOCAL_MACHINE\S…
A theme is a collection of property settings that allow you to define the look of pages and controls, and then apply the look consistently across pages in an application. Themes can be made up of a set of elements: skins, style sheets, images, and o…
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…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

747 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

10 Experts available now in Live!

Get 1:1 Help Now