public IProcess Start(ArgumentString arguments = default, bool createWindow = false, bool redirectInput = false, bool redirectOutput = false, Encoding outputEncoding = null) { // TODO should we set these on the child process only? EnvironmentConfiguration.SetEnvironmentVariables(); var args = (arguments.Arguments ?? "").Replace("$QUOTE$", "\\\""); var fileName = _fileNameProvider(); return(new ProcessWrapper(fileName, args, _workingDir, createWindow, redirectInput, redirectOutput, outputEncoding)); }
internal static Process StartProcess(string fileName, string arguments, string workingDirectory, Encoding outputEncoding) { EnvironmentConfiguration.SetEnvironmentVariables(); var startCmd = AppSettings.GitLog.Log(fileName, arguments); var startInfo = CreateProcessStartInfo(fileName, arguments, workingDirectory, outputEncoding); var startProcess = Process.Start(startInfo); startProcess.EnableRaisingEvents = true; void ProcessExited(object sender, EventArgs args) { startProcess.Exited -= ProcessExited; startCmd.LogEnd(); } startProcess.Exited += ProcessExited; return(startProcess); }
internal static Process StartProcess(string fileName, string arguments, string workingDirectory, Encoding outputEncoding) { EnvironmentConfiguration.SetEnvironmentVariables(); var operation = CommandLog.LogProcessStart(fileName, arguments); var startInfo = CreateProcessStartInfo(fileName, arguments, workingDirectory, outputEncoding); var process = Process.Start(startInfo); process.EnableRaisingEvents = true; operation.SetProcessId(process.Id); void ProcessExited(object sender, EventArgs args) { process.Exited -= ProcessExited; operation.LogProcessEnd(); } process.Exited += ProcessExited; return(process); }
/// <summary> /// Run command, console window is hidden, wait for exit, redirect output /// </summary> public static IEnumerable <string> ReadCmdOutputLines(string cmd, string arguments, string workDir, string stdInput) { EnvironmentConfiguration.SetEnvironmentVariables(); arguments = arguments.Replace("$QUOTE$", "\\\""); return(StartProcessAndReadLines(arguments, cmd, workDir, stdInput)); }