Code
Structure MyLUID
LowPart.l
HighPart.l
Attributes.l
EndStructure
Structure MyTOKEN
PrivilegeCount.l
LowPart.l
HighPart.l
Attributes.l
EndStructure
Procedure Restart()
tmpLuid.MyLUID
tkp.MyTOKEN
tkpNewButIgnored.MyTOKEN
hdlProcessHandle = GetCurrentProcess_()
OpenProcessToken_(hdlProcessHandle, #TOKEN_ADJUST_PRIVILEGES | #TOKEN_QUERY, @hdlTokenHandle)
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
Erg.l = AdjustTokenPrivileges_(hdlTokenHandle,0,@tkp,SizeOf(MyTOKEN),@tkpNewButIgnored,@lBufferNeeded)
Erg.l = ExitWindowsEx_((#EWX_REBOOT | #EWX_FORCE), 0)
EndProcedure
Restart()