girlswants_me
asked on
Force Reboot system
HOw can i FORCE REBOOT or RESTART WINDOWS XP.
Im making an Installer and i want to reboot the system, WINDOWS XP, please help!
Im making an Installer and i want to reboot the system, WINDOWS XP, please help!
Var tkp: TTokenPrivileges;
hToken : THandle;
if not OpenProcessToken( GetCurrentProcess, TOKEN_ADJUST_PRIVILEGES + TOKEN_QUERY, hToken) then
raise Exception.Create( 'Error when opening the process token');
LookupPrivilegeValue( nil,
'SeShutdownPrivilege',
tkp.Privileges[0].Luid);
tkp.PrivilegeCount := 1;
tkp.Privileges[0].Attribut es := SE_PRIVILEGE_ENABLED;
AdjustTokenPrivileges( hToken, False, tkp, 0, nil, l);
ExitWindowsEx( EWX_SHUTDOWN, 0);
hToken : THandle;
if not OpenProcessToken( GetCurrentProcess, TOKEN_ADJUST_PRIVILEGES + TOKEN_QUERY, hToken) then
raise Exception.Create( 'Error when opening the process token');
LookupPrivilegeValue( nil,
'SeShutdownPrivilege',
tkp.Privileges[0].Luid);
tkp.PrivilegeCount := 1;
tkp.Privileges[0].Attribut
AdjustTokenPrivileges( hToken, False, tkp, 0, nil, l);
ExitWindowsEx( EWX_SHUTDOWN, 0);
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
I forgot to add:
var l:dword;
and replace
ExitWindowsEx( EWX_SHUTDOWN, 0);
with
ExitWindowsEx( EWX_REBOOT, 0);
I tested just after what I put my comment .
var l:dword;
and replace
ExitWindowsEx( EWX_SHUTDOWN, 0);
with
ExitWindowsEx( EWX_REBOOT, 0);
I tested just after what I put my comment .
ASKER
This answers cant REBOOT my WINDOWS XP operating System.
have you everybody try it in WINDOWS XP?
have you everybody try it in WINDOWS XP?
>have you everybody try it in WINDOWS XP?
I tested it on XP and this works:
MyExitWindows(EWX_REBOOT or EWX_FORCE);
I tested it on XP and this works:
MyExitWindows(EWX_REBOOT or EWX_FORCE);
I tested my version on XP Pro and work fine .
ASKER
thanks for the help
ASKER