?
Solved

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

Posted on 2000-05-11
1
Medium Priority
?
222 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 300 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

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

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

If you have ever found yourself doing a repetitive action with the mouse and keyboard, and if you have even a little programming experience, there is a good chance that you can use a text editor to whip together a sort of macro to automate the proce…
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…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.

743 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