Skip to content

Commit 3493446

Browse files
committed
Support createNoWindow for start process api
1 parent 9119998 commit 3493446

File tree

2 files changed

+15
-6
lines changed

2 files changed

+15
-6
lines changed

Flow.Launcher.Plugin/Interfaces/IPublicAPI.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -613,8 +613,9 @@ public interface IPublicAPI
613613
/// <param name="arguments">Optional arguments to pass to the process. If not specified, no arguments will be passed</param>
614614
/// <param name="useShellExecute">Whether to use shell to execute the process</param>
615615
/// <param name="verb">Verb to use when starting the process, e.g. "runas" for elevated permissions. If not specified, no verb will be used.</param>
616+
/// <param name="createNoWindow">Whether to create console window</param>
616617
/// <returns>Whether process is started successfully</returns>
617-
public bool StartProcess(string fileName, string workingDirectory = "", string arguments = "", bool useShellExecute = false, string verb = "");
618+
public bool StartProcess(string fileName, string workingDirectory = "", string arguments = "", bool useShellExecute = false, string verb = "", bool createNoWindow = false);
618619

619620
/// <summary>
620621
/// Start a process with support for handling administrative privileges
@@ -627,7 +628,8 @@ public interface IPublicAPI
627628
/// <param name="argumentList">Optional argument list to pass to the process. If not specified, no arguments will be passed</param>
628629
/// <param name="useShellExecute">Whether to use shell to execute the process</param>
629630
/// <param name="verb">Verb to use when starting the process, e.g. "runas" for elevated permissions. If not specified, no verb will be used.</param>
631+
/// <param name="createNoWindow">Whether to create console window</param>
630632
/// <returns>Whether process is started successfully</returns>
631-
public bool StartProcess(string fileName, string workingDirectory = "", Collection<string> argumentList = null, bool useShellExecute = false, string verb = "");
633+
public bool StartProcess(string fileName, string workingDirectory = "", Collection<string> argumentList = null, bool useShellExecute = false, string verb = "", bool createNoWindow = false);
632634
}
633635
}

Flow.Launcher/PublicAPIInstance.cs

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -585,7 +585,7 @@ public long StopwatchLogInfo(string className, string message, Action action, [C
585585
public Task<long> StopwatchLogInfoAsync(string className, string message, Func<Task> action, [CallerMemberName] string methodName = "") =>
586586
Stopwatch.InfoAsync(className, message, action, methodName);
587587

588-
public bool StartProcess(string fileName, string workingDirectory = "", string arguments = "", bool useShellExecute = false, string verb = "")
588+
public bool StartProcess(string fileName, string workingDirectory = "", string arguments = "", bool useShellExecute = false, string verb = "", bool createNoWindow = false)
589589
{
590590
try
591591
{
@@ -597,7 +597,13 @@ public bool StartProcess(string fileName, string workingDirectory = "", string a
597597
var result = Win32Helper.RunAsDesktopUser(
598598
Constant.CommandExecutablePath,
599599
Environment.CurrentDirectory,
600-
$"-StartProcess -FileName {AddDoubleQuotes(fileName)} -WorkingDirectory {AddDoubleQuotes(workingDirectory)} -Arguments {AddDoubleQuotes(arguments)} -UseShellExecute {useShellExecute} -Verb {AddDoubleQuotes(verb)}",
600+
$"-StartProcess " +
601+
$"-FileName {AddDoubleQuotes(fileName)} " +
602+
$"-WorkingDirectory {AddDoubleQuotes(workingDirectory)} " +
603+
$"-Arguments {AddDoubleQuotes(arguments)} " +
604+
$"-UseShellExecute {useShellExecute} " +
605+
$"-Verb {AddDoubleQuotes(verb)} " +
606+
$"-CreateNoWindow {createNoWindow}",
601607
false,
602608
true, // Do not show the command window
603609
out var errorInfo);
@@ -616,6 +622,7 @@ public bool StartProcess(string fileName, string workingDirectory = "", string a
616622
Arguments = arguments,
617623
UseShellExecute = useShellExecute,
618624
Verb = verb,
625+
CreateNoWindow = createNoWindow
619626
};
620627
Process.Start(info)?.Dispose();
621628
return true;
@@ -627,8 +634,8 @@ public bool StartProcess(string fileName, string workingDirectory = "", string a
627634
}
628635
}
629636

630-
public bool StartProcess(string fileName, string workingDirectory = "", Collection<string> argumentList = null, bool useShellExecute = false, string verb = "") =>
631-
StartProcess(fileName, workingDirectory, JoinArgumentList(argumentList), useShellExecute, verb);
637+
public bool StartProcess(string fileName, string workingDirectory = "", Collection<string> argumentList = null, bool useShellExecute = false, string verb = "", bool createNoWindow = false) =>
638+
StartProcess(fileName, workingDirectory, JoinArgumentList(argumentList), useShellExecute, verb, createNoWindow);
632639

633640
private static string AddDoubleQuotes(string arg)
634641
{

0 commit comments

Comments
 (0)