Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

It's possible to shut down Windows by software, i.e. by clicking somewhere (Start button/Shutdown), or by using tools like shutdown.exe etc.

It's as well possible to shut down Windows by pressing the power button on the computer.

What's the difference? References, hard facts?

Notes/Clarifications/Backgrounds:

  • It always seemed to me pressing the power button will make Windows shut down much faster, especially with Windows XP: Computers in our corporate network running XP often took a complete minute to shut down via software, but they are always down after a few seconds when using the power button.
  • I know it's possible to configure what Windows should do when the power button is pressed.
  • I'm talking about pressing the power button for a very short amount of time, not holding it down for several seconds.
  • An ACPI spec, page 28: "What the system does with this request depends on policy issues derived from user preferences, user function requests, and application data." But what does Windows do?
  • I found a lot of conjectures and guesses while searching the internet, but I did not find any hard facts. Please do not provide more guesses, thank you.
share|improve this question
1  
@pnuts: Windows in general. I'm not thinking of a specific application. –  Martin May 23 '13 at 10:35

2 Answers 2

It's the same.

Like you said, you can force a shutdown by holding down the power button for longer (approximately 4 seconds), but this is literally cutting the power. An ACPI-initiated shutdown is the same as one you call through software. Both ways, all applications running on the machine have to be informed of the pending shutdown, (possibly abort it, depending on the version of Windows), and close themselves and any files they have open gracefully. That all takes time.

Basically, what makes the magic happen in either case is a call to the ExitWindowsEx function, which is part of the Windows API used by programmers.* If you specify the EWX_POWEROFF flag, the system is shut down and the power is turned off. It is also possible to call that function with the EWX_FORCE flag, which will do just what it sounds like—force a shutdown without giving running applications the ability to delay or cancel it. If you do that, shutdown will likely happen faster but it will not be a completely "clean" shutdown and is therefore dangerous.

The difference in behavior that you're seeing is probably due to way that the software shutdown is initiated. For example, when you execute shutdown.exe, you can indicate a timeout value for when the shutdown request should be initiated. During this period, the pending shutdown can be cancelled by running shutdown.exe again with the /a flag (to abort a pending shutdown). 60 seconds is a pretty common value for this timeout period.

The rest of the difference is probably just perceptual.

* The fact that Windows is a multi-user operating system can make things somewhat more complicated. But that's getting beyond the point here. Any other method of initiating a shutdown (e.g., InitiateSystemShutdown) is going to behave similarly.

share|improve this answer
    
OK. Do you have any references that pressing the power button effectively calls ExitWindowsEx, possibly with the EWX_FORCE flag? –  Martin May 23 '13 at 10:40
1  
I have observed that sometimes when selecting Windows button shutdown hangs (on Vista), pressing (but not holding) the power button will accomplish a shutdown. (Other times not.) –  Daniel R Hicks May 23 '13 at 11:10
    
@DanielRHicks: This could be a EWX_FORCE or EWX_FORCEIFHUNG flag. –  Martin May 23 '13 at 12:09

When you press the power button, the system is sent an ACPI signal indicating that the power button has been pressed. What the system does in response to this signal is determined by the system's settings. For Windows, the system may be configured to shut down, go to sleep, or hibernate when the power button is pressed.

In any case, the operating system responds to the power button being pressed and reacts in essentially the same manner as if you instructed the system to shut down, sleep, or hibernate through the menus or programmatically.

share|improve this answer
    
"reacts in essentially the same manner" - as I wrote, I'm pretty sure at least XP does not. However, where is this documented? –  Martin May 23 '13 at 7:59
2  
@Martin: In the case you mentioned, it is likely that the system is configured to sleep or hibernate rather than to shut down when the power button is pressed. This is often faster than a full shutdown. –  DragonLord May 23 '13 at 8:01
    
Err... I do know the difference between a shutdown and a sleep or hibernate :) It definitely was/is a shutdown. –  Martin May 23 '13 at 8:06
    
I don't know what to say, then. There really should not be a difference between pressing the power button to command the system to shut down and using the menus to do the same thing. –  DragonLord May 23 '13 at 8:13
    
Maybe you are right and I'm wrong and there indeed is no difference, but that's what I'd like to know some hard facts about. –  Martin May 23 '13 at 8:39

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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