@@ -23,6 +23,9 @@ public class Main : IPlugin, ISettingProvider, IPluginI18n
23
23
private Dictionary < string , string > KeywordTitleMappings = new Dictionary < string , string > ( ) ;
24
24
25
25
private const string SE_SHUTDOWN_NAME = "SeShutdownPrivilege" ;
26
+ // SHTDN_REASON_MAJOR_OTHER indicates a generic shutdown reason that isn't categorized under hardware failure, software updates, or other predefined reasons.
27
+ // SHTDN_REASON_FLAG_PLANNED marks the shutdown as planned rather than an unexpected shutdown or failure
28
+ private const SHUTDOWN_REASON REASON = SHUTDOWN_REASON . SHTDN_REASON_MAJOR_OTHER | SHUTDOWN_REASON . SHTDN_REASON_FLAG_PLANNED ;
26
29
27
30
public Control CreateSettingPanel ( )
28
31
{
@@ -163,13 +166,9 @@ private List<Result> Commands()
163
166
context . API . GetTranslation ( "flowlauncher_plugin_sys_shutdown_computer" ) ,
164
167
MessageBoxButton . YesNo , MessageBoxImage . Warning ) ;
165
168
166
- // SHTDN_REASON_MAJOR_OTHER indicates a generic shutdown reason that isn't categorized under hardware failure,
167
- // software updates, or other predefined reasons.
168
- // SHTDN_REASON_FLAG_PLANNED marks the shutdown as planned rather than an unexpected shutdown or failure
169
169
if ( result == MessageBoxResult . Yes )
170
170
if ( EnableShutdownPrivilege ( ) )
171
- PInvoke . ExitWindowsEx ( EXIT_WINDOWS_FLAGS . EWX_SHUTDOWN | EXIT_WINDOWS_FLAGS . EWX_POWEROFF ,
172
- SHUTDOWN_REASON . SHTDN_REASON_MAJOR_OTHER | SHUTDOWN_REASON . SHTDN_REASON_FLAG_PLANNED ) ;
171
+ PInvoke . ExitWindowsEx ( EXIT_WINDOWS_FLAGS . EWX_SHUTDOWN | EXIT_WINDOWS_FLAGS . EWX_POWEROFF , REASON ) ;
173
172
else
174
173
Process . Start ( "shutdown" , "/s /t 0" ) ;
175
174
@@ -191,8 +190,7 @@ private List<Result> Commands()
191
190
192
191
if ( result == MessageBoxResult . Yes )
193
192
if ( EnableShutdownPrivilege ( ) )
194
- PInvoke . ExitWindowsEx ( EXIT_WINDOWS_FLAGS . EWX_REBOOT ,
195
- SHUTDOWN_REASON . SHTDN_REASON_MAJOR_OTHER | SHUTDOWN_REASON . SHTDN_REASON_FLAG_PLANNED ) ;
193
+ PInvoke . ExitWindowsEx ( EXIT_WINDOWS_FLAGS . EWX_REBOOT , REASON ) ;
196
194
else
197
195
Process . Start ( "shutdown" , "/r /t 0" ) ;
198
196
@@ -214,8 +212,7 @@ private List<Result> Commands()
214
212
215
213
if ( result == MessageBoxResult . Yes )
216
214
if ( EnableShutdownPrivilege ( ) )
217
- PInvoke . ExitWindowsEx ( EXIT_WINDOWS_FLAGS . EWX_REBOOT | EXIT_WINDOWS_FLAGS . EWX_BOOTOPTIONS ,
218
- SHUTDOWN_REASON . SHTDN_REASON_MAJOR_OTHER | SHUTDOWN_REASON . SHTDN_REASON_FLAG_PLANNED ) ;
215
+ PInvoke . ExitWindowsEx ( EXIT_WINDOWS_FLAGS . EWX_REBOOT | EXIT_WINDOWS_FLAGS . EWX_BOOTOPTIONS , REASON ) ;
219
216
else
220
217
Process . Start ( "shutdown" , "/r /o /t 0" ) ;
221
218
@@ -236,8 +233,7 @@ private List<Result> Commands()
236
233
MessageBoxButton . YesNo , MessageBoxImage . Warning ) ;
237
234
238
235
if ( result == MessageBoxResult . Yes )
239
- PInvoke . ExitWindowsEx ( EXIT_WINDOWS_FLAGS . EWX_LOGOFF ,
240
- SHUTDOWN_REASON . SHTDN_REASON_MAJOR_OTHER | SHUTDOWN_REASON . SHTDN_REASON_FLAG_PLANNED ) ;
236
+ PInvoke . ExitWindowsEx ( EXIT_WINDOWS_FLAGS . EWX_LOGOFF , REASON ) ;
241
237
242
238
return true ;
243
239
}
0 commit comments