[DllImport("user32.dll")]
public static extern int ExitWindowsEx(int uFlags, int dwReason);
// Log Off
ExitWindowsEx(0, 0);
// Reboot
ExitWindowsEx(2, 0);
// Shutdown
ExitWindowsEx(1, 0);
// Force LogOff
ExitWindowsEx(4, 0);
و یا:
// Log Off
System.Diagnostics.Process.Start("ShutDown", "/l");
// Reboot
System.Diagnostics.Process.Start("ShutDown", "/r");
// Shutdown
System.Diagnostics.Process.Start("ShutDown", "/s");