@@ -187,7 +187,7 @@ private List<Result> ResultsFromHistory()
187
187
return history . ToList ( ) ;
188
188
}
189
189
190
- private ProcessStartInfo PrepareProcessStartInfo ( string command , bool runAsAdministrator = false ) //TODO: implement logic for CloseCMDAfterPress
190
+ private ProcessStartInfo PrepareProcessStartInfo ( string command , bool runAsAdministrator = false )
191
191
{
192
192
command = command . Trim ( ) ;
193
193
command = Environment . ExpandEnvironmentVariables ( command ) ;
@@ -203,7 +203,7 @@ private List<Result> ResultsFromHistory()
203
203
case Shell . Cmd :
204
204
{
205
205
info . FileName = "cmd.exe" ;
206
- info . Arguments = $ "{ ( _settings . LeaveShellOpen ? "/k" : "/c" ) } { command } { ( _settings . CloseShellAfterPress ? "& pause" : "" ) } ";
206
+ info . Arguments = $ "{ ( _settings . LeaveShellOpen ? "/k" : "/c" ) } { command } { ( _settings . CloseShellAfterPress ? $ "&& echo { context . API . GetTranslation ( "flowlauncher_plugin_cmd_press_any_key_to_close" ) } && pause > nul /c " : "" ) } ";
207
207
208
208
//// Use info.Arguments instead of info.ArgumentList to enable users better control over the arguments they are writing.
209
209
//// Previous code using ArgumentList, commands needed to be separated correctly:
@@ -232,11 +232,7 @@ private List<Result> ResultsFromHistory()
232
232
else
233
233
{
234
234
info . ArgumentList . Add ( "-Command" ) ;
235
- info . ArgumentList . Add ( command ) ;
236
- if ( _settings . CloseShellAfterPress )
237
- {
238
- info . ArgumentList . Add ( "; pause" ) ;
239
- }
235
+ info . ArgumentList . Add ( $ "{ command } ; { ( _settings . CloseShellAfterPress ? $ "Write-Host '{ context . API . GetTranslation ( "flowlauncher_plugin_cmd_press_any_key_to_close" ) } '; [System.Console]::ReadKey(); exit" : "" ) } ") ;
240
236
}
241
237
break ;
242
238
}
@@ -249,11 +245,7 @@ private List<Result> ResultsFromHistory()
249
245
info . ArgumentList . Add ( "-NoExit" ) ;
250
246
}
251
247
info . ArgumentList . Add ( "-Command" ) ;
252
- info . ArgumentList . Add ( command ) ;
253
- if ( _settings . CloseShellAfterPress )
254
- {
255
- info . ArgumentList . Add ( "; pause" ) ;
256
- }
248
+ info . ArgumentList . Add ( $ "{ command } ; { ( _settings . CloseShellAfterPress ? $ "Write-Host '{ context . API . GetTranslation ( "flowlauncher_plugin_cmd_press_any_key_to_close" ) } '; [System.Console]::ReadKey(); exit" : "" ) } ") ;
257
249
258
250
break ;
259
251
}
0 commit comments