Search code examples
c++windowswinapishutdownsystem-administration

AbortSystemShutdown on Windows 7 not working


I want to prevent shutdown on Windows 7. I acquire se_shutdown_privilege successfully, but AbortSystemShutdown is always failing. I tried AbortSystemShutdown(NULL), AbortSystemShutdown("127.0.0.1"), and AbortSystemShutdown(PcName).

So far no success.


Solution

  • Apparently, AbortSystemShutDown aborts a shutdown invoked by InitiateSystemShutdown (and the Ex version of that function) rather than, say, ExitWindows.

    The InitiateSystemShutdown and InitiateSystemShutdownEx functions display a dialog box that notifies the user that the system is shutting down. During the shutdown time-out period, the AbortSystemShutdown function can prevent the system from shutting down.