diff --git a/Plugins/Flow.Launcher.Plugin.Shell/Languages/en.xaml b/Plugins/Flow.Launcher.Plugin.Shell/Languages/en.xaml
index 88fa264d0..52aaf3c27 100644
--- a/Plugins/Flow.Launcher.Plugin.Shell/Languages/en.xaml
+++ b/Plugins/Flow.Launcher.Plugin.Shell/Languages/en.xaml
@@ -4,6 +4,7 @@
Replace Win+R
Close Command Prompt after pressing any key
+ Press any key to close this window...
Do not close Command Prompt after command execution
Always run as administrator
Run as different user
diff --git a/Plugins/Flow.Launcher.Plugin.Shell/Main.cs b/Plugins/Flow.Launcher.Plugin.Shell/Main.cs
index b963302db..f3c34d41d 100644
--- a/Plugins/Flow.Launcher.Plugin.Shell/Main.cs
+++ b/Plugins/Flow.Launcher.Plugin.Shell/Main.cs
@@ -187,7 +187,7 @@ namespace Flow.Launcher.Plugin.Shell
return history.ToList();
}
- private ProcessStartInfo PrepareProcessStartInfo(string command, bool runAsAdministrator = false) //TODO: implement logic for CloseCMDAfterPress
+ private ProcessStartInfo PrepareProcessStartInfo(string command, bool runAsAdministrator = false)
{
command = command.Trim();
command = Environment.ExpandEnvironmentVariables(command);
@@ -203,7 +203,7 @@ namespace Flow.Launcher.Plugin.Shell
case Shell.Cmd:
{
info.FileName = "cmd.exe";
- info.Arguments = $"{(_settings.LeaveShellOpen ? "/k" : "/c")} {command} {(_settings.CloseShellAfterPress ? "& pause" : "")}";
+ info.Arguments = $"{(_settings.LeaveShellOpen ? "/k" : "/c")} {command} {(_settings.CloseShellAfterPress ? $"&& echo {context.API.GetTranslation("flowlauncher_plugin_cmd_press_any_key_to_close")} && pause > nul /c" : "")}";
//// Use info.Arguments instead of info.ArgumentList to enable users better control over the arguments they are writing.
//// Previous code using ArgumentList, commands needed to be separated correctly:
@@ -232,11 +232,7 @@ namespace Flow.Launcher.Plugin.Shell
else
{
info.ArgumentList.Add("-Command");
- info.ArgumentList.Add(command);
- if (_settings.CloseShellAfterPress)
- {
- info.ArgumentList.Add("; pause");
- }
+ info.ArgumentList.Add($"{command}; {(_settings.CloseShellAfterPress ? $"Write-Host '{context.API.GetTranslation("flowlauncher_plugin_cmd_press_any_key_to_close")}'; [System.Console]::ReadKey(); exit" : "")}");
}
break;
}
@@ -249,11 +245,7 @@ namespace Flow.Launcher.Plugin.Shell
info.ArgumentList.Add("-NoExit");
}
info.ArgumentList.Add("-Command");
- info.ArgumentList.Add(command);
- if (_settings.CloseShellAfterPress)
- {
- info.ArgumentList.Add("; pause");
- }
+ info.ArgumentList.Add($"{command}; {(_settings.CloseShellAfterPress ? $"Write-Host '{context.API.GetTranslation("flowlauncher_plugin_cmd_press_any_key_to_close")}'; [System.Console]::ReadKey(); exit" : "")}");
break;
}