You can have a [shutdown] section in group policy which specifies some scripts to run during system shutdown. Do all these scripts run before Windows services start receiving 'Preshutdown' notifications (if they registered for those) or get 'Stop'-ped (if they didn't register for preshutdown)?

I just need to understand what order these things happen in, so I can figure out whether group policy shutdown scripts can take dependencies on Windows Services being available, etc. However its tough finding anything which actually discusses both of these subjects in one go!

  • Good question. Once Windows services begin shutting down, the operating system is no longer fully functional - so I would expect the scripts to run first, but I've never checked. – Harry Johnston Aug 30 '18 at 3:58

Well, I got to try it out. My experiments so far indicate that while the GP shutdown script runs first, before windows services are stopped during shutdown, during a real shutdown there still might be some kinds of dependencies on apps/API calls which can stop working (by the time your GP shutdown script is running).

Also I'm still in the dark as to how it compares to the 'preshutdown' notifications that services can register for.

  • 1
    Note that a shutdown script does not run in a normal interactive logon session, and this does introduce some limits on what it can do. The same is true of startup scripts. This is mostly just oddball things like printing, but YMMV. One way to (not entirely conclusively) disambiguate between "this isn't working because the system is starting up / shutting down" and "this isn't working because it isn't running in a normal logon session" is to try doing the same thing from a process launched using psexec with the -s flag. – Harry Johnston Aug 31 '18 at 21:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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