#247 Reboot instruction on Server 2012 R2

Unstable
closed-accepted
nobody
5
2014-06-27
2014-01-19
Stuart
No

While testing on Windows Server 2012 R2 I found that ExitWindowsEx (the Reboot instruction) does not actually reboot the machine if the installer was launched from a domain user. This is the case even if the original user was a domain administrator and the installer was elevated as a local administrator. The installer has the Windows 8.1 supported OS GUID embedded in its XML manifest and this has no effect.

The only situation where ExitWindowsEx reboots correctly is when the original logged in user is a local administrator. In every other case, the machine appears to do a quick reboot without a full power cycle. This means that operations that require a full reboot cycle never occur - such as replace on reboot operations (/rebootok).

The fix is to use the newer InitiateSystemShutdownEx API. I could not find anything about this on MSDN.

I have included a patch for NSIS 3.0a2 which calls InitiateSystemShutdownEx instead of ExitWindowsEx if it is available (uses myGetProcAddress). I have tested the Reboot instruction with the new code on Windows XP x86, Windows Vista x86, Windows Vista x64, Windows 7 x86, Windows 7 x64, Windows 8 x86, Windows 8 x64, Windows Server 2012 R2 x64.

1 Attachments

Discussion

  • Stuart
    Stuart
    2014-05-17

    I just tried the following, which also works:

    InitiateShutdown(NULL, NULL, 0, SHUTDOWN_RESTART | SHUTDOWN_FORCE_OTHERS | SHUTDOWN_GRACE_OVERRIDE, ...);

    As Anders has pointed out,

    I guess the only reason to use this is that the name is shorter and it is Vista+ only so it would never mess up NT5.

    Stu

     
  • Amir Szekely
    Amir Szekely
    2014-05-18

    Interesting:

    http://homepage.ntlworld.com/jonathan.deboynepollard/FGA/windows-nt-6-shutdown-process.html

    And from MSDN page on ExitWindowsEx:

    "The ExitWindowsEx function returns as soon as it has initiated the shutdown process. The shutdown or logoff then proceeds asynchronously. The function is designed to stop all processes in the caller's logon session. Therefore, if you are not the interactive user, the function can succeed without actually shutting down the computer. If you are not the interactive user, use the InitiateSystemShutdown orInitiateSystemShutdownEx function."

     
  • Stuart
    Stuart
    2014-05-31

    Here is a new patch for 3.0b0 which uses InitiateShutdown instead of InitiateSystemShutdownEx. I haven't built with it yet but I will try to find time soon (need to set up a VM).

    Stu

     
    Attachments
  • Anders
    Anders
    2014-06-27

    • status: open --> closed-accepted