I need some Windows 2012 servers to be shutdown properly with the power button.
- If nobody is logged, the power button correctly shuts down the server
- If somebody is logged without a blocking program, it's okay too
But:
- if a session is locked, the power button does nothing
- if somebody is logged with a blocking program (notepad with an unsaved document for example), the button does nothing too
With previous Windows versions I was used to configure the power button behaviour with the GUI and modify a registry key (HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\policies\system\shutdownwithoutlogon
) but this seems not any more relevant.
Does anyone knows the "offical" way, or a trick ?
Edit:
The system log display an event each time I press the power button. The kernel power manager has initiated a shutdown transition
with event ID 109.
When the session is locked, this event is followed by nothing. And no other events in other logs.
When a program refuse to close, I have the corresponding log entry, so this will be okay soon.
The fact you can't power down a 2012 server when a session is locked is probably by design. I faced a similar need and don't know any policy or registry change to allow that.
I used a simple trick: I captured the power button event which simply run my favorite shutdown.exe with the desired parameters after a timeout.
If you use the correct shutdown parameters, you won't be blocked by open programs.
To capture events, just open the task scheduler and create a task triggered on the desired event ID.
Check out AutoEndTasks:
You can set it for all users by creating the key here vs HKCU: HKEY_USERS.DEFAULT\Control Panel\Desktop
Additionally, there is some tuning that can be done via group policy that can be found here: Computer Configuration>Administrative Templates>System>Shutdown Options> Turn off automatic termination of applications that block or cancel shutdown
Additional tuning options that you may want to look into are: WaitToKillServiceTimeout,WaitToKillAppTimeout,HungAppTimeOut
I'll also second what MarcoZink stated, check your Bios and verify there isn't any special setting configured for your power button that may be holding things up.