Server Fault is a question and answer site for system and network administrators. 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

Is there a way to control the order in which services are stopped on a system shut-down?

We are having issues with our domain-controller, which takes forever to shut down (if it goes down at all) because of a mistake in the order the services are shut down (First domain services, then Exchange).

I could write a script to stop Exchange first and then shut down the machine, but would really like to be able to just issue a shutdown /r /t 1 and not have to think about it.

So, is there a way to control the order in which services are stopped/started on system stops/starts?

share|improve this question
up vote 3 down vote accepted

How to create a dependency between Windows services

  1. Run regedit to open your registry.
  2. Navigate to HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services and locate the service that you need to set a dependency for.
  3. Open the DependOnService key on the right side. If the selected service does not have a DependOnService key, then create one by right-clicking and selecting New > Multi-String Value.
  4. In the value field, enter the names of all services that the current service will depend on. Each service name must be entered properly and on a separate line.
  5. Click OK, close your registry and restart your machine.

You could use this method to force dependencies between services, but it is undocumented.

The real question is why is Exchange Server delaying the shutdown. Exchange shouldn't be delaying the system shutdown like this. It sounds like this real issue needs to be addressed.


If Exchange is on a domain controller then that will be the problem. It is caused by the simple fact that Exchange will only use itself for domain controller functions when installed on a DC, and when it is shutting down it needs to contact the domain controller. However during shutdown the domain controller functionality ends quicker than Exchange does. The delay is caused by the time Windows waits before it starts killing the services rather than letting them stop gracefully.

You can use a script to shutdown Exchange first and then restart the server. However the best option would be to get Exchange off that machine. Remember that you cannot remove the DC functionality while Exchange is installed. That is not supported and will often break Exchange. Exchange has to be removed first, or moved to another machine.

share|improve this answer
I like this one too, but I'm a mac/linux kinda guy, and the registry freaks me out a little bit. Maybe after a few beers :P. – Powertieke Sep 24 '10 at 20:33
@Powertieke - nope, this is the correct answer. It's the full version of what I posted, and was what I was fuzzily remembering. – mfinni Sep 24 '10 at 20:39
It appears to be a common issue with a domain controller which is also an exchange server. The 'hired' experts don't seem to be able to deal with it... – Powertieke Sep 24 '10 at 20:39
It's the way Windows defines dependencies between services. Technically the list of service dependences is passed to a CreateService API - that is the documented way to create dependencies between services (but since you didn't write the Exchange Server installer, you have no control over that). – Ian Boyd Sep 24 '10 at 20:41
@mfinni +1. Yes, i ran with your idea ;) – Ian Boyd Sep 24 '10 at 20:41

Write the script. Assign it to the computer as a shutdown script. This script will be processed before any services are stopped.

share|improve this answer
Any hints on where to assign the script as a shutdown script? – Powertieke Sep 24 '10 at 20:24
shutdown scripts aren't part of the Windows 2003 Scheduled Tasks. – Chris_K Sep 24 '10 at 20:30
Assign it via group policy – Jason Berg Sep 24 '10 at 21:10

Just guessing - can you make the Exchange service(s) dependent on the domain services? I should think Windows would then shut down Exchange first, before shutting down what they depend on.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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