@@ -194,10 +194,13 @@ private ProcessStartInfo PrepareProcessStartInfo(string command, bool runAsAdmin
194
194
var workingDirectory = Environment . GetFolderPath ( Environment . SpecialFolder . UserProfile ) ;
195
195
var runAsAdministratorArg = ! runAsAdministrator && ! _settings . RunAsAdministrator ? "" : "runas" ;
196
196
197
- ProcessStartInfo info = new ( )
197
+ var info = new ProcessStartInfo ( )
198
198
{
199
- Verb = runAsAdministratorArg , WorkingDirectory = workingDirectory ,
199
+ Verb = runAsAdministratorArg ,
200
+ WorkingDirectory = workingDirectory ,
200
201
} ;
202
+ var notifyStr = Context . API . GetTranslation ( "flowlauncher_plugin_cmd_press_any_key_to_close" ) ;
203
+ var addedCharacter = _settings . UseWindowsTerminal ? "\\ " : "" ;
201
204
switch ( _settings . Shell )
202
205
{
203
206
case Shell . Cmd :
@@ -211,16 +214,26 @@ private ProcessStartInfo PrepareProcessStartInfo(string command, bool runAsAdmin
211
214
{
212
215
info . FileName = "cmd.exe" ;
213
216
}
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
+ "" ) } " ) ;
216
230
break ;
217
231
}
218
232
219
233
case Shell . Powershell :
220
234
{
221
235
// Using just a ; doesn't work with wt, as it's used to create a new tab for the terminal window
222
236
// \\ must be escaped for it to work properly, or breaking it into multiple arguments
223
- var addedCharacter = _settings . UseWindowsTerminal ? "\\ " : "" ;
224
237
if ( _settings . UseWindowsTerminal )
225
238
{
226
239
info . FileName = "wt.exe" ;
@@ -238,7 +251,11 @@ private ProcessStartInfo PrepareProcessStartInfo(string command, bool runAsAdmin
238
251
else
239
252
{
240
253
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
+ "" ) } " ) ;
242
259
}
243
260
break ;
244
261
}
@@ -247,7 +264,6 @@ private ProcessStartInfo PrepareProcessStartInfo(string command, bool runAsAdmin
247
264
{
248
265
// Using just a ; doesn't work with wt, as it's used to create a new tab for the terminal window
249
266
// \\ must be escaped for it to work properly, or breaking it into multiple arguments
250
- var addedCharacter = _settings . UseWindowsTerminal ? "\\ " : "" ;
251
267
if ( _settings . UseWindowsTerminal )
252
268
{
253
269
info . FileName = "wt.exe" ;
@@ -262,7 +278,11 @@ private ProcessStartInfo PrepareProcessStartInfo(string command, bool runAsAdmin
262
278
info . ArgumentList . Add ( "-NoExit" ) ;
263
279
}
264
280
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
+ "" ) } " ) ;
266
286
break ;
267
287
}
268
288
0 commit comments