private static Process StartProcessAndReadAllText(string arguments, string cmd, string workDir, out string stdOutput, out string stdError, string stdInput) { if (string.IsNullOrEmpty(cmd)) { stdOutput = stdError = ""; return(null); } //process used to execute external commands var process = StartProcess(cmd, arguments, workDir, GitModule.SystemEncoding); if (!string.IsNullOrEmpty(stdInput)) { process.StandardInput.Write(stdInput); process.StandardInput.Close(); } SynchronizedProcessReader.Read(process, out stdOutput, out stdError); return(process); }
internal static int CreateAndStartProcess(string arguments, string cmd, string workDir, out string stdOutput, out string stdError, string stdInput) { if (string.IsNullOrEmpty(cmd)) { stdOutput = stdError = ""; return(-1); } string quotedCmd = cmd; if (quotedCmd.IndexOf(' ') != -1) { quotedCmd = quotedCmd.Quote(); } Settings.GitLog.Log(quotedCmd + " " + arguments); //process used to execute external commands var startInfo = CreateProcessStartInfo(null); startInfo.CreateNoWindow = true; startInfo.FileName = cmd; startInfo.Arguments = arguments; startInfo.WorkingDirectory = workDir; startInfo.LoadUserProfile = true; using (var process = Process.Start(startInfo)) { if (!string.IsNullOrEmpty(stdInput)) { process.StandardInput.Write(stdInput); process.StandardInput.Close(); } SynchronizedProcessReader.Read(process, out stdOutput, out stdError); process.WaitForExit(); return(process.ExitCode); } }