Solved

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

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

Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

Question has a verified solution.

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

Suggested Solutions

This article surveys and compares options for encoding and decoding base64 data.  It includes source code in C++ as well as examples of how to use standard Windows API functions for these tasks. We'll look at the algorithms — how encoding and decodi…
What my article will show is if you ever had to do processing to a listbox without being able to just select all the items in it. My software Visual Studio 2008 crystal report v11 My issue was I wanted to add crystal report to a form and show…
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…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

735 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