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

I have a Windows service A that depends on service B.

According to this Microsoft KB article I can add a registry key to tell Windows to wait until B starts before starting A.

Can I therefore expect service A to be shut down before B when I shut down Windows?

share|improve this question
up vote 1 down vote accepted

Unfortunately not prior to Windows Vista.

Here's the word from the horse's mouth:

Windows Vista (and newer versions) have a "Service Shutdown Ordering" feature. This is controlled by the "PreShutDownOrder" registry value (briefly mentioned in

Searching "PreShutDownOrder" with "" on Google is returning an unhelpfully low number of results. It looks like it's only quasi-documented by Microsoft. I'd play around with it and see if it does what you want.

Here's a blog entry that mentions it from the "Ask Perf" blog (a really great blog, BTW, if you like knowing about Windows innards):

share|improve this answer
Is this still valid for 2003/2008 servers? – pauska Jul 1 '09 at 12:48
I've dropped another edit on this with some more info on a "PreShutDownOrder" feature that proports to be in Windows Vista and above, but seems to be very poorly documented. – Evan Anderson Jul 1 '09 at 12:53… – fjsj May 7 '15 at 22:09

A service who has other services depedent on it shuts down the other services before shutting it self when you do it manually.

Edit: Evan Anderson posted a link about it not using depdencies when shutting down the OS in case of running on UPS etc. It's a good and valid point (allthough it doesnt mention Windows newer than 2000.)

share|improve this answer
Service B might be unaware of Service A, so it cannot be expected to do anything. Windows, on the other hand, should but doesn't. – Ed Guiness Jul 1 '09 at 12:52
No, if you do the registry settings that you posted then service B will see service A as depedant on it. – pauska Jul 1 '09 at 12:54
Service B will only be aware of this registry key if it explicitly goes looking for it. Many services don't. It is not there for the benefit of services, it is there for the operating system, so it can work out which services to start first. – Ed Guiness Jul 1 '09 at 15:51
In my scenario, Service A is a service written by me, Service B is sql server. Sql server knows nothing about my service (nor should it) and therefore has no sensitivity to shutting down while my service is running. Do you see? – Ed Guiness Jul 1 '09 at 15:53
Doesnt that depend on how the service shuts down? Net stop and similar atleast takes attention to depedencies, but anyways: If you are talking about system shutdown then the poster above have the correct answwer. – pauska Jul 1 '09 at 19:10

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.