2 * PROJECT: ReactOS Automatic Testing Utility
3 * LICENSE: GNU GPLv2 or any later version as published by the Free Software Foundation
4 * PURPOSE: Helper function for shutting down the system
5 * COPYRIGHT: Copyright 2008-2009 Colin Finck <colin@reactos.org>
11 * Shuts down the system.
14 * true if everything went well, false if there was a problem while trying to shut down the system.
19 TOKEN_PRIVILEGES Privileges
;
21 if (!OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES
, &hToken
))
23 StringOut("OpenProcessToken failed\n");
27 /* Get the LUID for the Shutdown privilege */
28 if (!LookupPrivilegeValueW(NULL
, SE_SHUTDOWN_NAME
, &Privileges
.Privileges
[0].Luid
))
30 StringOut("LookupPrivilegeValue failed\n");
34 /* Assign the Shutdown privilege to our process */
35 Privileges
.PrivilegeCount
= 1;
36 Privileges
.Privileges
[0].Attributes
= SE_PRIVILEGE_ENABLED
;
38 if (!AdjustTokenPrivileges(hToken
, FALSE
, &Privileges
, 0, NULL
, NULL
))
40 StringOut("AdjustTokenPrivileges failed\n");
44 /* Finally shut down the system */
45 if(!ExitWindowsEx(EWX_POWEROFF
, SHTDN_REASON_MAJOR_OTHER
| SHTDN_REASON_MINOR_OTHER
| SHTDN_REASON_FLAG_PLANNED
))
47 StringOut("ExitWindowsEx failed\n");