2

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?

2 Answers 2

1

Unfortunately not prior to Windows Vista.

Here's the word from the horse's mouth: http://support.microsoft.com/kb/203878

Windows Vista (and newer versions) have a "Service Shutdown Ordering" feature. This is controlled by the "PreShutDownOrder" registry value (briefly mentioned in http://technet.microsoft.com/en-us/magazine/2007.03.vistakernel.aspx).

Searching "PreShutDownOrder" with "site:microsoft.com" 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): https://techcommunity.microsoft.com/t5/Ask-The-Performance-Team/WS2008-Service-Shutdown-and-Crash-Handling/ba-p/372708

3
  • Is this still valid for 2003/2008 servers?
    – pauska
    Jul 1, 2009 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. Jul 1, 2009 at 12:53
  • serverfault.com/questions/24821/…
    – fjsj
    May 7, 2015 at 22:09
0

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.)

5
  • 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, 2009 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, 2009 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, 2009 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, 2009 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, 2009 at 19:10

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .