=====Shutting down the PC===== //by Richard Russell, October 2007//\\ \\ It's not a very likely thing to want to do, but the code below **shuts down** the PC when executed. Note that if run under //Windows 2000 Professional//, //Windows XP Professional// or //Windows Vista// it's entirely likely that the system adminstrator will have disabled the ability of ordinary user programs to shut down the PC. In that case the program will fail with the //Cannot acquire Shutdown privilege// message. REM. Caution: this program shuts down the computer! SYS "GetCurrentProcess" TO hprocess% _TOKEN_ADJUST_PRIVILEGES = &20 _TOKEN_QUERY = 8 SYS "OpenProcessToken", hprocess%, \ \ _TOKEN_ADJUST_PRIVILEGES OR _TOKEN_QUERY, ^htoken% _SE_PRIVILEGE_ENABLED = 2 DIM tkp{PrivilegeCount%, Luid{l%,h%}, Attributes%} tkp.PrivilegeCount% = 1 tkp.Attributes% = _SE_PRIVILEGE_ENABLED SYS "LookupPrivilegeValue", "", "SeShutdownPrivilege", ^tkp.Luid.l% SYS "AdjustTokenPrivileges", htoken%, 0, tkp{}, 0, 0, 0 TO ok% IF ok% = 0 ERROR 100, "Cannot acquire Shutdown privilege" _EWX_POWEROFF = 8 SYS "ExitWindowsEx", _EWX_POWEROFF, &FFFF TO ok% IF ok% PRINT "System shutting down...." You may alternatively wish to change the **_EWX_POWEROFF** value to **_EWX_SHUTDOWN** ("=1") which doesn't turn the power off or **_EWX_REBOOT** ("=2") which restarts the system.