Search code examples
sessionwindows-server-2008-r2shutdownblocked

Windows server power off button and blocked sessions


We have one windows Server 2008 R2 installation and we need the power button to trigger the server's shutdown procedure.

Generally this works as expected, but when there's a blocked session the shutdown does not happen.

I have googled this requirement wide and far, but I have been unable to find anything related.


Solution

  • You could use the Windows Task Scheduler to create a task triggered by the power button event (I'm not sure about the EventID, perhaps 109 or 1074).

    The task will call the shutdown command:

    shutdown /s /d p:0:0
    
    • /s shutdown command to the local computer
    • /d this records the reason for the shut down (p is planned and 0:0 indicates an "Other" reason)