Problem rebooting console app

  • Thread starter Thread starter Brady Kelly
  • Start date Start date
B

Brady Kelly

When I use the ExitWindowsEx function in my C# console application it
doesn't reboot. Any ideas why?
 
Brady,

Goblins? Your doing it wrong? Please provide us with a bit more
information,
such as the API declaration and call as well as any errors you might be
getting etc
so we wont have to play the guessing game =)

//Andreas
 
Brady,

Goblins? Your doing it wrong? Please provide us with a bit more
information,
such as the API declaration and call as well as any errors you might be
getting etc
so we wont have to play the guessing game =)

I'm using the WindowsController class from The KPD-Team at
http://www.mentalis.org/.

The declarations are, in only the necessary detail:

public enum RestartOptions {
Reboot = 2,
}

[ DllImport( "user32.dll", EntryPoint="ExitWindowsEx",
CharSet=CharSet.Ansi )]
private static extern int ExitWindowsEx(int uFlags, int dwReserved);

....
EnableToken("SeShutdownPrivilege");
if (ExitWindowsEx(RestartOptions.Reboot | EWX_FORCE, 0) == 0)
throw new Exception.......

I'm not getting an exception, so it looks like the call is
'apparently' working. The strangest is that the application restarts,
not the system.
 
Back
Top