Check Process.Start usage

This commit is contained in:
Jack251970 2025-06-15 01:16:46 +08:00
parent e1242eefda
commit e5316a0ac4
6 changed files with 14 additions and 11 deletions

View file

@ -367,7 +367,8 @@ namespace Flow.Launcher
UseShellExecute = true, UseShellExecute = true,
Verb = Win32Helper.IsAdministrator() || forceAdmin ? "runas" : "" Verb = Win32Helper.IsAdministrator() || forceAdmin ? "runas" : ""
}; };
Process.Start(startInfo); // No need to de-elevate since we are restarting // No need to de-elevate since we are restarting Flow Launcher which cannot bring security risks
Process.Start(startInfo);
Thread.Sleep(500); Thread.Sleep(500);
Environment.Exit(0); Environment.Exit(0);

View file

@ -360,11 +360,7 @@ namespace Flow.Launcher.Plugin.Explorer
{ {
try try
{ {
Process.Start(new ProcessStartInfo() Main.Context.API.StartProcess(editorPath, arguments: record.FullPath);
{
FileName = editorPath,
ArgumentList = { record.FullPath }
});
return true; return true;
} }
catch (Exception e) catch (Exception e)
@ -394,10 +390,7 @@ namespace Flow.Launcher.Plugin.Explorer
{ {
try try
{ {
Process.Start(new ProcessStartInfo() Main.Context.API.StartProcess(shellPath, workingDirectory: record.FullPath);
{
FileName = shellPath, WorkingDirectory = record.FullPath
});
return true; return true;
} }
catch (Exception e) catch (Exception e)
@ -462,6 +455,7 @@ namespace Flow.Launcher.Plugin.Explorer
Arguments = "srchadmin.dll" Arguments = "srchadmin.dll"
}; };
// No need to de-elevate since we are opening windows settings which cannot bring security risks
Process.Start(psi); Process.Start(psi);
return true; return true;
} }
@ -486,6 +480,7 @@ namespace Flow.Launcher.Plugin.Explorer
SubTitle = Context.API.GetTranslation("plugin_explorer_openwith_subtitle"), SubTitle = Context.API.GetTranslation("plugin_explorer_openwith_subtitle"),
Action = _ => Action = _ =>
{ {
// No need to de-elevate since we are opening windows settings which cannot bring security risks
Process.Start("rundll32.exe", $"{Path.Combine(Environment.SystemDirectory, "shell32.dll")},OpenAs_RunDLL {record.FullPath}"); Process.Start("rundll32.exe", $"{Path.Combine(Environment.SystemDirectory, "shell32.dll")},OpenAs_RunDLL {record.FullPath}");
return true; return true;
}, },

View file

@ -57,7 +57,7 @@ namespace Flow.Launcher.Plugin.Explorer.Search.Everything
} }
Settings.EverythingInstalledPath = installedPath; Settings.EverythingInstalledPath = installedPath;
Process.Start(installedPath, "-startup"); Main.Context.API.StartProcess(installedPath, arguments: "-startup");
return true; return true;
} }

View file

@ -488,6 +488,7 @@ namespace Flow.Launcher.Plugin.Explorer.ViewModels
Arguments = Constants.WindowsIndexingOptions Arguments = Constants.WindowsIndexingOptions
}; };
// No need to de-elevate since we are opening windows settings which cannot bring security risks
Process.Start(psi); Process.Start(psi);
} }

View file

@ -210,6 +210,7 @@ namespace Flow.Launcher.Plugin.Sys
if (EnableShutdownPrivilege()) if (EnableShutdownPrivilege())
PInvoke.ExitWindowsEx(EXIT_WINDOWS_FLAGS.EWX_SHUTDOWN | EXIT_WINDOWS_FLAGS.EWX_POWEROFF, REASON); PInvoke.ExitWindowsEx(EXIT_WINDOWS_FLAGS.EWX_SHUTDOWN | EXIT_WINDOWS_FLAGS.EWX_POWEROFF, REASON);
else else
// No need to de-elevate since we already have message box asking for confirmation
Process.Start("shutdown", "/s /t 0"); Process.Start("shutdown", "/s /t 0");
return true; return true;
@ -231,6 +232,7 @@ namespace Flow.Launcher.Plugin.Sys
if (EnableShutdownPrivilege()) if (EnableShutdownPrivilege())
PInvoke.ExitWindowsEx(EXIT_WINDOWS_FLAGS.EWX_REBOOT, REASON); PInvoke.ExitWindowsEx(EXIT_WINDOWS_FLAGS.EWX_REBOOT, REASON);
else else
// No need to de-elevate since we already have message box asking for confirmation
Process.Start("shutdown", "/r /t 0"); Process.Start("shutdown", "/r /t 0");
return true; return true;
@ -252,6 +254,7 @@ namespace Flow.Launcher.Plugin.Sys
if (EnableShutdownPrivilege()) if (EnableShutdownPrivilege())
PInvoke.ExitWindowsEx(EXIT_WINDOWS_FLAGS.EWX_REBOOT | EXIT_WINDOWS_FLAGS.EWX_BOOTOPTIONS, REASON); PInvoke.ExitWindowsEx(EXIT_WINDOWS_FLAGS.EWX_REBOOT | EXIT_WINDOWS_FLAGS.EWX_BOOTOPTIONS, REASON);
else else
// No need to de-elevate since we already have message box asking for confirmation
Process.Start("shutdown", "/r /o /t 0"); Process.Start("shutdown", "/r /o /t 0");
return true; return true;
@ -315,6 +318,7 @@ namespace Flow.Launcher.Plugin.Sys
Glyph = new GlyphInfo (FontFamily:"/Resources/#Segoe Fluent Icons", Glyph:"\xe773"), Glyph = new GlyphInfo (FontFamily:"/Resources/#Segoe Fluent Icons", Glyph:"\xe773"),
Action = c => Action = c =>
{ {
// No need to de-elevate since we are opening windows settings which cannot bring security risks
Process.Start("control.exe", "srchadmin.dll"); Process.Start("control.exe", "srchadmin.dll");
return true; return true;
} }
@ -351,6 +355,7 @@ namespace Flow.Launcher.Plugin.Sys
CopyText = recycleBinFolder, CopyText = recycleBinFolder,
Action = c => Action = c =>
{ {
// No need to de-elevate since we are opening windows settings which cannot bring security risks
Process.Start("explorer", recycleBinFolder); Process.Start("explorer", recycleBinFolder);
return true; return true;
} }

View file

@ -208,6 +208,7 @@ namespace Flow.Launcher.Plugin.WindowsSettings.Helper
{ {
processStartInfo.UseShellExecute = true; processStartInfo.UseShellExecute = true;
processStartInfo.Verb = "runas"; processStartInfo.Verb = "runas";
// No need to de-elevate since we are opening windows settings which cannot bring security risks
Process.Start(processStartInfo); Process.Start(processStartInfo);
return true; return true;
} }