How to ensure that service is start after another service

Posted on 2005-03-02
Medium Priority
Last Modified: 2008-01-09

I have written a Windows Service that relies on SQL Service and 2 other custom services, but on start up, sometimes, my service is started before those ones, and I'm getting errors. Is there a way to enforce a service start only after some other service is started, and similarly, once some other service has been stopped, cascade it on all dependant services.

Thank you
Question by:RodionP
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
LVL 10

Accepted Solution

heintalus earned 1000 total points
ID: 13444109
When you add your installer to your service it has a ServicesDependedOn Property where you can specify other services that yours depends on.

Quote from online Help :-
The information from this property is written to a key in the registry. When the user (or the system, in the case of automatic startup) tries to run the service, the Service Control Manager (SCM) verifies that each of the services in the array has already been started.

If any service in the array is not running then, the SCM tries to start them. This includes services with Manual StartType.

If any service upon which this service depends fails to start, this service will not start.


Author Comment

ID: 13445297
Any code examples would be appreciated
LVL 11

Expert Comment

ID: 13445815

Check out here.

You have to use this property to ensure that particular service had started. Then you can initate to start secound service.

Hope you got it.

LVL 10

Expert Comment

ID: 13445982
You dont need code to do it, have you added an installer to your service ?

If so open it up & select the serviceInstaller, have a look at it's properties & you will see one called ServicesDepended on which is a string array for all services that it depends upon, simple add the names of any services you want to this array via the properties window, for example if your service depends on Microsoft Message Queueing you'd add in MSMQ i.e. the service name you see if you look at the services properties from within Services.


Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: Najam
Having new technologies does not mean they will completely replace old components.  Recently I had to create WCF that will be called by VB6 component.  Here I will describe what steps one should follow while doing so, please feel free to post any qu…
Introduction Although it is an old technology, serial ports are still being used by many hardware manufacturers. If you develop applications in C#, Microsoft .NET framework has SerialPort class to communicate with the serial ports.  I needed to…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
Suggested Courses
Course of the Month7 days, 23 hours left to enroll

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question