6

I'm looking for a way to force Windows XP Pro SP3 to display the 'It's now safe to turn off your computer' screen when doing a shutdown.

The reason behind is that I want my UPS to turn off/on the power at some point and the PC should startup automatically again after the power cycle. In the BIOS this can be configured so that the PC powers on automatically if it sees power is being restored, but only if the PC was running before the power went away initially.

It seems it was possible to force this in Windows XP < SP1 by calling ExitWindowsEx with the EWX_SHUTDOWN uFlags parameter

See here for details

So why was this removed in SP1 and higher?

Any other ways to force this?

3
  • I suspect that was about the time that computers all came with the ACPI power functions (and hardware) that allowed software to turn off a computer. XP also improved considerably over its lifetime to gracefully handle power-off events in the middle of day-day activities. Previously, shutting down when not 'permitted' caused all kinds of problems if you remember I guess your use-case wasn't seen as common enough. Can't think of a bomb-proof workaround. Perhaps you could force a log-off instead - not sure if that would safely close the required programs.
    – enhzflep
    Commented Dec 3, 2013 at 14:27
  • @phuclv I see you followed the comment link as well :P
    – Clonkex
    Commented Jun 22, 2018 at 5:09
  • Go into the BIOS and look for the AC power loss option. Most if not all computers can be configured to one of three states after the mains power returns - switch on, stay off, or return to the last state. I usually set all my computers to "switch on" because I want them to come on after a blackout in case I am not around, and I can always shut them down again remotely if needed.
    – Malvineous
    Commented Feb 12, 2021 at 0:05

1 Answer 1

8

After two days of searching, I finally solved it, well actually a colleague of mine :-) !

Read this article for the details: https://web.archive.org/web/20140209015215/http://support.microsoft.com/kb/819760

Essentially it comes down to running:

reg add HKLM\Software\Policies\Microsoft\Windows NT /v DontPowerOffAfterShutdown /t REG_DWORD /d 1 /f

And then calling ExitWindowsEx with option EWX_SHUTDOWN from my application.

2
  • 2
    This works for Windows 10 too. This was required for me to shut down windows avoiding corruption/recovery of windows startup - I shutdown computer with wizmo.exe silent exit! and it shuts down, but still with power on, and after a minute or so, I power off with timer, creating failed power state, but windows was successfully shut down. After turning on again with timer, it resumes previous power state (which was on), and I have created timer controlled Windows PC.
    – Deele
    Commented Mar 8, 2016 at 19:32
  • @Deele Why did you need to create a failed power state, couldn't you set the BIOS to automatically power on after AC power loss? Also most BIOSes can power on at a specific time every day so it has always been possible to switch them on and off at specific times without any extra hardware since the late 90s.
    – Malvineous
    Commented Feb 12, 2021 at 0:02

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