PC herunterfahren
Verfasst: 03.11.2006 21:37
Hallo,
weiß jemand einen Befehl, mit dem man den PC runterfahren kann?
weiß jemand einen Befehl, mit dem man den PC runterfahren kann?

Code: Alles auswählen
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)
Code: Alles auswählen
RunProgram("C:\Windows\System32\shutdown.exe","-s -t 0 -f","",0)
Code: Alles auswählen
RunProgram("C:\Windows\System32\shutdown.exe","-s -t 0 -f",0)
Dies ist nur bei WinXP oder anderen NT-Versionen vorhanden. Win98 geht da nicht mit. Da funzt das mit der rundll.RSBasic hat geschrieben:@Fluid Byte
Warum so schwer?
Einfacher mit diesem Befehl:Für PB 3.30:Code: Alles auswählen
RunProgram("C:\Windows\System32\shutdown.exe","-s -t 0 -f","",0)
Code: Alles auswählen
RunProgram("C:\Windows\System32\shutdown.exe","-s -t 0 -f",0)
Code: Alles auswählen
ExitWindowsEx_((#EWX_LOGOFF), 0)
Code: Alles auswählen
Procedure Privilegien()
#EWX_LOGOFF = 0
#EWX_SHUTDOWN = 1
#EWX_REBOOT = 2
#EWX_FORCE = 4
#EWX_POWEROFF = 8
#TOKEN_ADJUST_PRIVILEGES = 32
#TOKEN_QUERY = 8
#SE_PRIVILEGE_ENABLED = 2
#ANYSIZE_ARRAY = 1
#VER_PLATFORM_WIN32_NT = 2
#SE_SHUTDOWN_NAME = "SeShutdownPrivilege"
Structure MyLUID
LowPart.l
HighPart.l
Attributes.l
EndStructure
Structure MyTOKEN
PrivilegeCount.l
LowPart.l
HighPart.l
Attributes.l
EndStructure
Global hdlProcessHandle.l
Global hdlTokenHandle.l
Global tmpLuid.MyLUID
Global tkp.MyToken
Global tkpNewButIgnored.MyToken
Global lBufferNeeded.l
hdlProcessHandle = GetCurrentProcess_()
OpenProcessToken_(hdlProcessHandle, #TOKEN_ADJUST_PRIVILEGES | #TOKEN_QUERY, @hdlTokenHandle)
; Get the LUID for shutdown privilege
SysName.s = "" + Chr(0)
Name.s = "SeShutdownPrivilege" + Chr(0)
Erg.l = LookupPrivilegeValue_(SysName, Name, @tmpLuid)
tmpLuid\Attributes = #SE_PRIVILEGE_ENABLED
tkp\PrivilegeCount = 1
tkp\LowPart = tmpLuid\LowPart
tkp\HighPart = tmpLuid\HighPart
tkp\Attributes = tmpLuid\Attributes
; Enable the shutdown privilege in the access token of this process
Erg.l = AdjustTokenPrivileges_(hdlTokenHandle, 0, @tkp, SizeOf(MyTOKEN), @tkpNewButIgnored, @lblBufferNeeded)
EndProcedure
Code: Alles auswählen
#EWX_LOGOFF = 0
#EWX_SHUTDOWN = 1
#EWX_REBOOT = 2
#EWX_FORCE = 4
#EWX_POWEROFF = 8