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

I have a Windows service on Windows Server 2008 R2 that I set-up using instsrv on the srvany.exe executable. The three values in the Parameters key are set as follows:

AppDirectory  C:\selenium-grid
Application   C:\ant\bin\ant.bat
AppParameters launch-hub

The service starts fine and two Java processes appear in the Task Manager when it starts (one process is ant and the other is a Java class launched by ant). When I stop the service the status of the service changes to stopped but the two Java processes do not go away.

How do I get the processes to stop when I stop the service?

share|improve this question
    
whats in ant.bat if there is more then one exe in there that may be the issue. –  tony roth Oct 7 '11 at 23:17
1  
Is this an installation of the srvany.exe service? –  Harry Johnston Oct 8 '11 at 0:31
    
Yes, the service install uses srvany.exe. I have added that clarification to the question. –  user35042 Oct 8 '11 at 2:12
    
One process is ant itself while the other is a Java class launched by ant. (Updated the question to clarify this.) –  user35042 Oct 8 '11 at 2:19

3 Answers 3

Unvortunately, SRVANY sucks. There is an alternative which is the "Non-Sucking Service Manager" (NSSM) - it will shut down your application and all child processes on the service stop signal.

share|improve this answer

Unfortunately, srvany.exe does not provide any method for killing the process(es) when the service is stopped, so basically your options are to (a) look for a third-party alternative which does provide this functionality or (b) write such a replacement yourself.

Perhaps another reader knows about a good third-party alternative, or you might get lucky with a Google search. If you decide to go with option (b) I may be able to give you a head start, so drop me an email if you like - my address is in my profile. Or you could post a question to StackOverflow.

share|improve this answer

Srvany has a few well known shortcomings, one of which is not terminating the process it starts.

Be sure to read about other potential issues on this page comparing Srvany to AlwaysUp (our commercial application which will close all sub-processes as you expect) to reduce the surprises...

share|improve this answer

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.