Solved

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

Posted on 2000-05-11
1
219 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

Question has a verified solution.

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

For most people, the WrapPanel seems like a magic when they switch from WinForms to WPF. Most of us will think that the code that is used to write a control like that would be difficult. However, most of the work is done by the WPF engine, and the W…
Entering time in Microsoft Access can be difficult. An input mask often bothers users more than helping them and won't catch all typing errors. This article shows how to create a textbox for 24-hour time input with full validation politely catching …
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…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

717 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