private static PreparedProcess StartProcess([NotNull] ChildProcessStartInfo childProcessStartInfo) { var processStartInfo = new ProcessStartInfo(childProcessStartInfo.ProcessFileName); childProcessStartInfo.Arguments.CopyTo(processStartInfo); if (childProcessStartInfo.WorkingDirectory != null) { processStartInfo.WorkingDirectory = childProcessStartInfo.WorkingDirectory; } // necessary for redirecting streams processStartInfo.UseShellExecute = false; // don't pop up a new console window when running the process processStartInfo.CreateNoWindow = true; processStartInfo.RedirectStandardOutput = true; processStartInfo.RedirectStandardError = true; var process = new Process { StartInfo = processStartInfo, }; return(new PreparedProcess(process, childProcessStartInfo)); }
public static ChildProcessResult Exec([NotNull] ChildProcessStartInfo startInfo) { Verify.ParamNotNull(startInfo, nameof(startInfo)); var runningProcess = StartProcess(startInfo); return(runningProcess.Execute()); }
public PreparedProcess([NotNull] Process process, [NotNull] ChildProcessStartInfo startInfo) { Verify.ParamNotNull(process, nameof(process)); Verify.ParamNotNull(startInfo, nameof(startInfo)); this.m_process = process; this.m_startInfo = startInfo; }
private static ChildProcessStartInfo CreateChildProcessStartInfo( [NotNull] string processFileName, [CanBeNull] ProcessArguments arguments, [CanBeNull] string workingDirectory, int?successExitCode ) { var startInfo = new ChildProcessStartInfo(processFileName) { WorkingDirectory = workingDirectory, SuccessExitCode = successExitCode, }; if (arguments != null) { startInfo.Arguments.AddRange(arguments); } return(startInfo); }
public static async Task <ChildProcessResult> ExecAsync([NotNull] ChildProcessStartInfo startInfo) { var runningProcess = StartProcess(startInfo); return(await runningProcess.ExecuteAsync()); }