diff --git a/Plugins/Flow.Launcher.Plugin.Sys/Main.cs b/Plugins/Flow.Launcher.Plugin.Sys/Main.cs index d0eb339fe..b53c0261b 100644 --- a/Plugins/Flow.Launcher.Plugin.Sys/Main.cs +++ b/Plugins/Flow.Launcher.Plugin.Sys/Main.cs @@ -210,16 +210,16 @@ namespace Flow.Launcher.Plugin.Sys Localize.flowlauncher_plugin_sys_dlgtext_shutdown_computer(), Localize.flowlauncher_plugin_sys_shutdown_computer(), MessageBoxButton.YesNo, MessageBoxImage.Warning); - - // Save settings before shutdown to avoid data loss - Context.API.SaveAppAllSettings(); - if (result == MessageBoxResult.Yes) + { + // Save settings before shutdown to avoid data loss + Context.API.SaveAppAllSettings(); + if (EnableShutdownPrivilege()) PInvoke.ExitWindowsEx(EXIT_WINDOWS_FLAGS.EWX_SHUTDOWN | EXIT_WINDOWS_FLAGS.EWX_POWEROFF, REASON); else Process.Start("shutdown", "/s /t 0"); - + } return true; } }, @@ -234,16 +234,16 @@ namespace Flow.Launcher.Plugin.Sys Localize.flowlauncher_plugin_sys_dlgtext_restart_computer(), Localize.flowlauncher_plugin_sys_restart_computer(), MessageBoxButton.YesNo, MessageBoxImage.Warning); - - // Save settings before restart to avoid data loss - Context.API.SaveAppAllSettings(); - if (result == MessageBoxResult.Yes) + { + // Save settings before restart to avoid data loss + Context.API.SaveAppAllSettings(); + if (EnableShutdownPrivilege()) PInvoke.ExitWindowsEx(EXIT_WINDOWS_FLAGS.EWX_REBOOT, REASON); else Process.Start("shutdown", "/r /t 0"); - + } return true; } }, @@ -258,16 +258,16 @@ namespace Flow.Launcher.Plugin.Sys Localize.flowlauncher_plugin_sys_dlgtext_restart_computer_advanced(), Localize.flowlauncher_plugin_sys_restart_computer(), MessageBoxButton.YesNo, MessageBoxImage.Warning); - - // Save settings before restart to avoid data loss - Context.API.SaveAppAllSettings(); - if (result == MessageBoxResult.Yes) + { + // Save settings before restart to avoid data loss + Context.API.SaveAppAllSettings(); + if (EnableShutdownPrivilege()) PInvoke.ExitWindowsEx(EXIT_WINDOWS_FLAGS.EWX_REBOOT | EXIT_WINDOWS_FLAGS.EWX_BOOTOPTIONS, REASON); else Process.Start("shutdown", "/r /o /t 0"); - + } return true; } },