You can't - oddly enough this professional grade software is not geared towards your decidedly home-based usage requirement - therefore it does not have any form of code built in to detect a button press and trigger a shutdown.
Why not try a consumer product such as VMWare's Workstation which is much more likely to be scriptable in this manner.
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.
Best Answer
To change the actions that the server takes when it receives an ACPI event indicating the power button, edit the:
/etc/acpi/powerbtn.sh
script.This will not prevent holding the button to force power off, however.
While we're at it, the line in /etc/inittab:
Controls the action taken upon pressing C-A-D.