Take the 2-minute tour ×

I have a Windows Service that makes use of a SQL Server database. I don't have control over the installation of the service, but would like to add a dependency on the service to ensure that it starts after SQL server has started. (SQL server is running on the same machine as the service in question)

Is there a tool to add a dependency or possibly editing the registry directly?

share|improve this question

3 Answers 3

up vote 83 down vote accepted

This can also be done via an elevated command prompt using the sc command. The syntax is:

sc config [service name] depend= <Dependencies(separated by / (forward slash))>

Note: There is a space after the equals sign, and there is not one before it.

Warning: depend= parameter will overwrite existing dependencies list, not append. So for example, if ServiceA already depends on ServiceB and ServiceC, if you run depend= ServiceD, ServiceA will now depend only on ServiceD. (Thanks Matt!)


Dependency on one other service:

sc config ServiceA depend= ServiceB

Above means that ServiceA will not start until ServiceB has started. If you stop ServiceB, ServiceA will stop automatically.

Dependency on multiple other services:

sc config ServiceA depend= ServiceB/ServiceC/ServiceD

Above means that ServiceA will not start until ServiceB, ServiceC, and ServiceD have all started. If you stop any of ServiceB, ServiceC, or ServiceD, ServiceA will stop automatically.

To remove all dependencies:

sc config ServiceA depend= /

To list current dependencies:

sc qc ServiceA
share|improve this answer
I had originally select the answer indicating how to edit the registry. But using the SC command is more in line with what I was looking for. Thx. –  Rick Jan 29 '11 at 21:54
If you want to see the existing dependencies before changing them with Kip's method, you can type sc qc YourServiceName –  mivk Oct 1 '11 at 17:43
Just be careful... I just used this and didn't realize that it will overwrite existing dependencies.. there were two for my service that I don't remember.. now they're gone.. oh well! So make sure you run the command @mivk mentioned first to see any other dependencies first. –  Matt Mar 28 '13 at 15:49
@Matt good point, i will add a warning. –  Kip Mar 29 '13 at 17:55
If like me, your Service has spaces in the name, enclose it in quotes. –  Lazlow Mar 18 at 8:46

I wrote a simple .net application to manage service dependencies, if you are interested. It's free.


share|improve this answer
It is telling me I need .NET 1.1 but I am running windows 7 –  Nick Jun 17 at 17:41
.Net 1.1 needs to be installed on Windows 7. See the answer to this question: answers.microsoft.com/en-us/windows/forum/… –  Glenn Sullivan Jun 18 at 18:29

You can add service dependencies by adding the "DependOnService" value to the service in the registry using the regedit command, services can be found under HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\<Service name>. The details can be found at MS KB article 193888, from which the following is an excerpt from:

To create a new dependency, select the subkey representing the service you want to delay, click Edit, and then click Add Value. Create a new value name "DependOnService" (without the quotation marks) with a data type of REG_MULTI_SZ, and then click OK. When the Data dialog box appears, type the name or names of the services that you prefer to start before this service with one entry for each line, and then click OK.

share|improve this answer
Holy Cow! That was the fastest answer I've ever received. I barely got back to the home page. –  Rick Jun 12 '09 at 14:55
+1 Thanks, worked for me. –  Rich Sep 10 '13 at 15:25

Your Answer


