Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a service that needs to be started only AFTER another service. Is there some way to configure the service to only start once another has finished starting?

Obviously, I could use a delayed start or write a batch script to do this, but they are both messy / temporary solutions. So I wondered if I can schedule for this to happen somehow?

Can it be done?

share|improve this question
What version of Windows? – JNK Sep 14 '10 at 14:02
Windows Server 2008 – rmx Sep 14 '10 at 14:17
up vote 4 down vote accepted

In my experience, the best way to create service dependencies, without rummaging in the registry (something that is not secure, safe, or easily scriptable == repeatable) is to use SC.exe - the service control utility packaged with every Windows version since Win2003.

You can open a command window and type sc to get the full help, but the gist of it is:

sc create newservice binpath= c:\nt\system32\newserv.exe type= own start= auto depend= "netbios"

Creates a new service, named "newservice", points to its path, makes it start automatically and makes it dependent on the NetBIOS service.

Read more about SC here.

share|improve this answer

You have to use the registry editor (as far as I know) to make the service depend on the other server. Locate the dependent service in HKLM\SYSTEM\CurrentControlSet\services, and add an REG_MULTI_SZ value called DependOnService. Put the service name (not the display name, but the same name as it's reg key) as a value.

When you reboot now, Windows will only start your dependent service after the service you made it depend on starts. Likewise, if the service it depends on fails to start, your dependent service will not start either.

share|improve this answer
Brilliant. I am not sure how happy my buildmaster will be about poking around in the registry though... They definately need to add this functionality, I can't imagine this is a unique problem – rmx Sep 14 '10 at 14:21
Here's the Microsoft Support article on this topic. – Phrogz May 4 '11 at 16:30

As long as the service is deployed properly in webcontainer, when you start the tomcat, it would automatically starts the service just like any other web application. Please be aware that webservice deployed in webcontainer is nothing but a service wrapped in a servlet which looks for SOAP request over HTTP just like any other servlet.

share|improve this answer

You could make the second service dependent on the first service, and then start the second service instead of the first service. Windows will make sure that the first service is started before starting the second service.

share|improve this answer
the flip side of this is that you can't run service A without service B ALSO running...which may be OK for this purposes but he should be aware of it. – JNK Sep 14 '10 at 14:11
Thanks. I just found the dependencies tab for the service but there are no options to set or add dependencies - how can I do that? @JNK that's not an issue here but good point – rmx Sep 14 '10 at 14:15
You can certainly have service A run without service B, unless we've gotten our A's and B's confused. E.g., the Fax service (service B, or the second service) depends on the Print Spooler service (service A, or the first service), but starting Print Spooler doesn't also start Fax. Starting Fax will start Print Spooler. – dsolimano Sep 14 '10 at 14:18
@sdolimano - I was backwards, sorry. It's a moot point according to OP anyways... – JNK Sep 14 '10 at 14:19
@rmx, you can look at or Coding Gorilla's answer. – dsolimano Sep 14 '10 at 14:19

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .