Sometimes, you want to configure a Windows system so that it shows a message when shutting down. In my case, it's to remind me (because I'm too bone-headed to remember!) to unmount any shares on the relevant box, since otherwise it tends to make the machine where I have them mounted...unhappy.
It's easy to do: First, create the script you want to run, perhaps:
WScript.Echo("Remember to unmount the shares!");
...in a file somewhere (
shutdownmsg.js, in my case).
Now, we tell Windows to run that on shutdown:
- Run gpedit.msc
- Navigate to Local Computer Policy > Computer Configuration > Administrative Templates > System > Scripts
- Change the setting for Run shutdown scripts visible to Enabled (if you don't do this, your machine will basically hang on shutdown, waiting for you to reply to a dialog box you can't see)
- Navigate to Local Computer Policy > Computer Configuration > Windows Settings > Scripts (Startup / Shutdown)
- Double-click Shutdown
- Click Add and add your script (in my case,
- Close gpedit
That's it! Now when you shut down, the dialog box will appear and stop the entire process until you dismiss it. Conveniently for me, this happens before the network stuff is shut down, so I can unmount my drives cleanly.