Link to home
Start Free TrialLog in
Avatar of girlswants_me
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!
Avatar of girlswants_me
girlswants_me

ASKER

help me please
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].Attributes := SE_PRIVILEGE_ENABLED;
AdjustTokenPrivileges( hToken, False, tkp, 0, nil, l);
ExitWindowsEx( EWX_SHUTDOWN, 0);  
ASKER CERTIFIED SOLUTION
Avatar of Tasomia
Tasomia

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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 .
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?

I tested it on XP and this works:

MyExitWindows(EWX_REBOOT or EWX_FORCE);
I tested my version on XP Pro and work fine .
thanks for the help