diff --git a/Flow.Launcher.Plugin/Interfaces/IPublicAPI.cs b/Flow.Launcher.Plugin/Interfaces/IPublicAPI.cs index 9e3d279ab..8c02151be 100644 --- a/Flow.Launcher.Plugin/Interfaces/IPublicAPI.cs +++ b/Flow.Launcher.Plugin/Interfaces/IPublicAPI.cs @@ -591,7 +591,8 @@ namespace Flow.Launcher.Plugin /// Working directory. If not specified, the current directory will be used /// Optional arguments to pass to the process. If not specified, no arguments will be passed /// Whether to run the process as administrator - public void StartProcess(string filePath, string workingDirectory = "", string arguments = "", bool runAsAdmin = false); + /// Whether process is started successfully + public bool StartProcess(string filePath, string workingDirectory = "", string arguments = "", bool runAsAdmin = false); /// /// Displays a User Account Control (UAC) dialog to request elevated permissions for the specified application. diff --git a/Flow.Launcher/PublicAPIInstance.cs b/Flow.Launcher/PublicAPIInstance.cs index 6a4a4493d..d02b718d0 100644 --- a/Flow.Launcher/PublicAPIInstance.cs +++ b/Flow.Launcher/PublicAPIInstance.cs @@ -577,7 +577,7 @@ namespace Flow.Launcher public Task StopwatchLogInfoAsync(string className, string message, Func action, [CallerMemberName] string methodName = "") => Stopwatch.InfoAsync(className, message, action, methodName); - public void StartProcess(string filePath, string workingDirectory = "", string arguments = "", bool runAsAdmin = false) + public bool StartProcess(string filePath, string workingDirectory = "", string arguments = "", bool runAsAdmin = false) { try { @@ -590,8 +590,10 @@ namespace Flow.Launcher if (!string.IsNullOrEmpty(errorInfo)) { LogError(ClassName, $"Failed to start process {filePath} with error: {errorInfo}"); + return false; } - return; + + return true; } var info = new ProcessStartInfo @@ -603,10 +605,12 @@ namespace Flow.Launcher Verb = runAsAdmin ? "runas" : "", }; Process.Start(info)?.Dispose(); + return true; } catch (Exception e) { LogException(ClassName, $"Failed to start process {filePath} with arguments {arguments} under {workingDirectory}", e); + return false; } }