From d41dd780ce631d1ef0aa61dd53a68204bb85fc72 Mon Sep 17 00:00:00 2001 From: Spencer Hedrick Date: Sat, 9 Oct 2021 02:36:38 -0700 Subject: [PATCH] add initial ShellRun support for JsonRPC --- Flow.Launcher.Plugin/Interfaces/IPublicAPI.cs | 6 ++++++ Flow.Launcher/PublicAPIInstance.cs | 10 ++++++++++ 2 files changed, 16 insertions(+) diff --git a/Flow.Launcher.Plugin/Interfaces/IPublicAPI.cs b/Flow.Launcher.Plugin/Interfaces/IPublicAPI.cs index d9cdf5581..3cadae176 100644 --- a/Flow.Launcher.Plugin/Interfaces/IPublicAPI.cs +++ b/Flow.Launcher.Plugin/Interfaces/IPublicAPI.cs @@ -29,6 +29,12 @@ namespace Flow.Launcher.Plugin /// void RestartApp(); + /// + /// Run a shell command or external program + /// + /// The command or program to run + void ShellRun(string cmd); + /// /// Save everything, all of Flow Launcher and plugins' data and settings /// diff --git a/Flow.Launcher/PublicAPIInstance.cs b/Flow.Launcher/PublicAPIInstance.cs index 6f995671d..c528b8229 100644 --- a/Flow.Launcher/PublicAPIInstance.cs +++ b/Flow.Launcher/PublicAPIInstance.cs @@ -103,6 +103,16 @@ namespace Flow.Launcher }); } + public void ShellRun(string cmd) + { + System.Diagnostics.Process process = new(); + var startInfo = process.StartInfo; + startInfo.FileName = "cmd.exe"; + startInfo.Arguments = $"/C {cmd}"; + startInfo.CreateNoWindow = true; + process.Start(); + } + public void StartLoadingBar() => _mainVM.ProgressBarVisibility = Visibility.Visible; public void StopLoadingBar() => _mainVM.ProgressBarVisibility = Visibility.Collapsed;