In my case, I have a power outage scheduled at a remote location—the power company is going to kill the power to do utility work for about 4 hours—and I really don't want to drive out to the remote location just to turn the server back on.
What I'd prefer to do is use remote access to put the server in a state that is "safe" for the operating system (i.e., I/O is flushed and volumes are clean dismounted), but it is still "on" so that when the power comes back on after being off for a while, the server will happily reboot.
Mind you: I have this server on a UPS, so its power won't fail until the UPS is fairly well depleted and shuts itself off; it won't power back on until the UPS has recharged enough to keep the server running for 20+ minutes. This will eliminate issues with the power company flipping things on-and-off while doing their work, as well as the very good potential for a surge when they finally get things turned back up.
Of course, this could have all been avoided if I had the BIOS set to power-on the server on whenever the power state switches from OFF to ON. However, there are any number of reasons why it's not currently set this way, and resetting it would require two things: driving to the remote site (which I want to avoid) and scheduling an outage because there's no way to edit this particular BIOS setting via administrative software (too bad, eh?). In some ways, resetting the BIOS is a worse option than what I'm after.
So what's the trick?
- You have to enable a policy for the system
- Use software (not the START button) to initiate the shutdown.
One can enable the policy in several ways, but the end result is the following registry key being set:
System Key: HKLM\SOFTWARE\Policies\Microsoft\Windows NTThis policy is only observed when software is used to perform the shutdown (like UPS management software, which we haven't got for our server, as the UPS is an old horse without a modern USB interface. Yeah, I know: it also means that the UPS doesn't properly shutdown the system during unplanned outages, but that's an issue for another day...). If you use the START button/Taskbar to perform a shutdown (which is the typical method for a planned/expected shutdown), it will ignore the setting and power down after shutdown.
Value Name: DontPowerOffAfterShutdown
Data Type: REG_DWORD
Value Data: 1 (0 = power off, 1 = stay on)
Personally, I'll be using "shutdown -s -t5" to shutdown 5 seconds after the command is issued.
Other caveats: this policy only works for Windows OSes after XP SP1, and there are known issues with some Pre-SP1 Windows 2003 servers (see Microsoft KB 819760 for more details on that) that might not result in success.