From fc53efd6a6254778320b8bd8db54dd306008315d Mon Sep 17 00:00:00 2001 From: Jack251970 <1160210343@qq.com> Date: Wed, 11 Jun 2025 16:04:17 +0800 Subject: [PATCH] Use new api function to open application --- .../Programs/Win32.cs | 32 +++---------------- 1 file changed, 5 insertions(+), 27 deletions(-) diff --git a/Plugins/Flow.Launcher.Plugin.Program/Programs/Win32.cs b/Plugins/Flow.Launcher.Plugin.Program/Programs/Win32.cs index 4e1d99454..e3dec1c60 100644 --- a/Plugins/Flow.Launcher.Plugin.Program/Programs/Win32.cs +++ b/Plugins/Flow.Launcher.Plugin.Program/Programs/Win32.cs @@ -208,38 +208,16 @@ namespace Flow.Launcher.Plugin.Program.Programs private void Launch(bool elevated = false) { - var info = new ProcessStartInfo + if (Main.IsAdmin && elevated) { - FileName = FullPath, - WorkingDirectory = ParentDirectory, - UseShellExecute = true, - Verb = elevated ? "runas" : "", - }; - - if (Main.IsAdmin) - { - if (elevated) + // Since we are already elevated, we need to create UAC dialog manually + if (UACDialog.Show(IcoPath, Name, FullPath) != MessageBoxResult.Yes) { - // Since we are already elevated, we need to create UAC dialog manually - if (UACDialog.Show(IcoPath, Name, FullPath) != MessageBoxResult.Yes) - { - return; - } - } - else - { - // Use explorer.exe as workaround to start process as standard user - info = new ProcessStartInfo - { - FileName = "explorer.exe", - Arguments = $"\"{FullPath}\"", - WorkingDirectory = ParentDirectory, - UseShellExecute = true, - }; + return; } } - _ = Task.Run(() => Main.StartProcess(Process.Start, info)).ConfigureAwait(false); + _ = Task.Run(() => Main.Context.API.StartProcess(FullPath, ParentDirectory, "", elevated)).ConfigureAwait(false); } public List ContextMenus(IPublicAPI api)