Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have a bunch of processes on a server that I want to update the exes regurlary. But before update they must be closed and I use PsKill for that in a bat-file. It works but I seek a way to only send a "Quit Query" to the processes so it shuts down more properly. With PsKill it is done by force.

How can this be done ?

share|improve this question
    
I don't think we can answer this without knowing which processes. You probably need to contact the developer of the process to find out how to do this. –  Iain Jul 19 '11 at 7:54
    
Barbaric! If your executable needs to be shut down prior to an upgrade you should have it respond to an appropriate command, not brutally and rudely kill it like that, which can result in system instability that you'll have no end of trouble debugging. –  John Gardeniers Jul 20 '11 at 2:59
add comment

1 Answer

up vote 2 down vote accepted

When talking about executables on a server I assume you are talking about services.

If so, you can stop them using "net stop " i.e. "net stop certsvc", otherwise if the executables run in interactive mode, e.g. in a console session and have a window you can use the Windows API to find the application's window and send WM_SYSCOMMAND with SC_CLOSE as parameter.

Here is an example: http://www.codeproject.com/KB/dialog/closewindow.aspx.

share|improve this answer
    
That's some creative thinking there. I was about to write an answer just stating "It can't be done", but I've leart something today :) –  Mark Henderson Jul 20 '11 at 0:31
    
In this case it was an ordinary window with GUI. But of course you are right. It can be done with a little program that call WinAPI. –  berocoder Jul 21 '11 at 6:41
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.