@@ -194,10 +194,13 @@ private ProcessStartInfo PrepareProcessStartInfo(string command, bool runAsAdmin
194194 var workingDirectory = Environment . GetFolderPath ( Environment . SpecialFolder . UserProfile ) ;
195195 var runAsAdministratorArg = ! runAsAdministrator && ! _settings . RunAsAdministrator ? "" : "runas" ;
196196
197- ProcessStartInfo info = new ( )
197+ var info = new ProcessStartInfo ( )
198198 {
199- Verb = runAsAdministratorArg , WorkingDirectory = workingDirectory ,
199+ Verb = runAsAdministratorArg ,
200+ WorkingDirectory = workingDirectory ,
200201 } ;
202+ var notifyStr = Context . API . GetTranslation ( "flowlauncher_plugin_cmd_press_any_key_to_close" ) ;
203+ var addedCharacter = _settings . UseWindowsTerminal ? "\\ " : "" ;
201204 switch ( _settings . Shell )
202205 {
203206 case Shell . Cmd :
@@ -211,16 +214,26 @@ private ProcessStartInfo PrepareProcessStartInfo(string command, bool runAsAdmin
211214 {
212215 info . FileName = "cmd.exe" ;
213216 }
214-
215- info . ArgumentList . Add ( $ "{ ( _settings . LeaveShellOpen ? "/k" : "/c" ) } { command } { ( _settings . CloseShellAfterPress ? $ "&& echo { Context . API . GetTranslation ( "flowlauncher_plugin_cmd_press_any_key_to_close" ) } && pause > nul /c" : "" ) } ") ;
217+ if ( _settings . LeaveShellOpen )
218+ {
219+ info . ArgumentList . Add ( "/k" ) ;
220+ }
221+ else
222+ {
223+ info . ArgumentList . Add ( "/c" ) ;
224+ }
225+ info . ArgumentList . Add (
226+ $ "{ command } " +
227+ $ "{ ( _settings . CloseShellAfterPress ?
228+ $ " && echo { notifyStr } && pause > nul /c" :
229+ "" ) } " ) ;
216230 break ;
217231 }
218232
219233 case Shell . Powershell :
220234 {
221235 // Using just a ; doesn't work with wt, as it's used to create a new tab for the terminal window
222236 // \\ must be escaped for it to work properly, or breaking it into multiple arguments
223- var addedCharacter = _settings . UseWindowsTerminal ? "\\ " : "" ;
224237 if ( _settings . UseWindowsTerminal )
225238 {
226239 info . FileName = "wt.exe" ;
@@ -238,7 +251,11 @@ private ProcessStartInfo PrepareProcessStartInfo(string command, bool runAsAdmin
238251 else
239252 {
240253 info . ArgumentList . Add ( "-Command" ) ;
241- info . ArgumentList . Add ( $ "{ command } { addedCharacter } ; { ( _settings . CloseShellAfterPress ? $ "Write-Host '{ Context . API . GetTranslation ( "flowlauncher_plugin_cmd_press_any_key_to_close" ) } '{ addedCharacter } ; [System.Console]::ReadKey(){ addedCharacter } ; exit" : "" ) } ") ;
254+ info . ArgumentList . Add (
255+ $ "{ command } { addedCharacter } ;" +
256+ $ "{ ( _settings . CloseShellAfterPress ?
257+ $ " Write-Host '{ notifyStr } '{ addedCharacter } ; [System.Console]::ReadKey(){ addedCharacter } ; exit" :
258+ "" ) } " ) ;
242259 }
243260 break ;
244261 }
@@ -247,7 +264,6 @@ private ProcessStartInfo PrepareProcessStartInfo(string command, bool runAsAdmin
247264 {
248265 // Using just a ; doesn't work with wt, as it's used to create a new tab for the terminal window
249266 // \\ must be escaped for it to work properly, or breaking it into multiple arguments
250- var addedCharacter = _settings . UseWindowsTerminal ? "\\ " : "" ;
251267 if ( _settings . UseWindowsTerminal )
252268 {
253269 info . FileName = "wt.exe" ;
@@ -262,7 +278,11 @@ private ProcessStartInfo PrepareProcessStartInfo(string command, bool runAsAdmin
262278 info . ArgumentList . Add ( "-NoExit" ) ;
263279 }
264280 info . ArgumentList . Add ( "-Command" ) ;
265- info . ArgumentList . Add ( $ "{ command } { addedCharacter } ; { ( _settings . CloseShellAfterPress ? $ "Write-Host '{ Context . API . GetTranslation ( "flowlauncher_plugin_cmd_press_any_key_to_close" ) } '{ addedCharacter } ; [System.Console]::ReadKey(){ addedCharacter } ; exit" : "" ) } ") ;
281+ info . ArgumentList . Add (
282+ $ "{ command } { addedCharacter } ;" +
283+ $ "{ ( _settings . CloseShellAfterPress ?
284+ $ " Write-Host '{ notifyStr } '{ addedCharacter } ; [System.Console]::ReadKey(){ addedCharacter } ; exit" :
285+ "" ) } " ) ;
266286 break ;
267287 }
268288
0 commit comments