public Exec(string cmd, string args) { Proc = new Process { StartInfo = { FileName = cmd, Arguments = args, UseShellExecute = false, CreateNoWindow = true, RedirectStandardOutput = true, RedirectStandardError = true, WorkingDirectory = Directory.GetCurrentDirectory() } }; Proc.OutputDataReceived += POutputDataReceived; Proc.ErrorDataReceived += PErrorDataReceived; // TODO: This is a hack for mergetool: We need to show the window to ask the user if the merge succeeded. // The problem is with .NET (and MONO!) buffering of streams prevents us to catching the question on time. if (args.StartsWith("mergetool ")) { Proc.StartInfo.CreateNoWindow = false; Proc.StartInfo.RedirectStandardOutput = false; Proc.StartInfo.RedirectStandardError = false; } // Add all environment variables registered for our process environment foreach (var variable in ClassUtils.GetEnvars()) { // If a variable with that name already exists, update it if (Proc.StartInfo.EnvironmentVariables.ContainsKey(variable.Key)) { Proc.StartInfo.EnvironmentVariables[variable.Key] = variable.Value; } else { Proc.StartInfo.EnvironmentVariables.Add(variable.Key, variable.Value); } } }