7

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?

4
  • 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
7

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.

2

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.

1

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...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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