Procedure ExitWindows(Flags.l) Protected tkp.TOKEN_PRIVILEGES Protected tkpNewButIgnored.TOKEN_PRIVILEGES OpenProcessToken_(GetCurrentProcess_(),#TOKEN_ADJUST_PRIVILEGES | #TOKEN_QUERY,@hdlTokenHandle) ; Get the LUID for shutdown privilege. LookupPrivilegeValue_(0,"SeShutdownPrivilege",tkp\Privileges\Luid) tkp\PrivilegeCount = 1 ; One privilege to set tkp\Privileges\Attributes = #SE_PRIVILEGE_ENABLED ; Enable the shutdown privilege in the access token of this process. AdjustTokenPrivileges_(hdlTokenHandle,0,tkp,0,0,0) ExitWindowsEx_(Flags,0) EndProcedure ExitWindows(#EWX_SHUTDOWN)