My Tech Scrap
Flipkart.com

Translate

Share |

Tuesday, 31 December 2013

How to Create a Windows Service Dependency (Server 2003/2008)

For 2003 server this can be done by all users having admin privilages from the command prompt.
For 2008 server this should be done via an elevated command prompt (right click and runs as administrator) using the sc command. The syntax is:

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

Points to remember
depend= parameter will overwrite existing dependencies. So for example, if Service_1 already depends on Service_2 and Service_3, if you run depend= Service_4, Service_1 will now depend only on Service_4.

Examples
Dependency on single service:

sc config Service_1 depend= Service_2
Above means that Service_1 will not start until Service_2 has started. If you stop Service_2, Service_1 will stop automatically.

Dependency on multiple services:
sc config Service_1 depend= Service_2/Service_3/Service_4
Above means that Service_1 will not start until Service_2, Service_3, and Service_4 are started. If you stop any of Service_2, Service_3, or Service_4, Service_1 will stop automatically.

Remove all dependencies:
sc config Service_1 depend= /
List current dependencies:
sc qc Service_1

 

No comments:

Post a Comment