using System; using System.Diagnostics; using System.Linq; static class Program { static int Main(string[] args) { var p = new ProcessStartInfo { FileName = args[0], // TODO: quote args Arguments = String.Join(" ", args.Skip(1).ToArray()), RedirectStandardInput = true, RedirectStandardError = true, RedirectStandardOutput = true, UseShellExecute = false }; var process = Process.Start(p); process.BeginOutputReadLine(); process.OutputDataReceived += (s, e) => Console.Out.WriteLine(e.Data); process.BeginErrorReadLine(); process.OutputDataReceived += (s, e) => Console.Error.WriteLine(e.Data); string l; while ((l = Console.ReadLine()) != null) { process.StandardInput.WriteLine(l); process.StandardInput.Flush(); } process.StandardInput.Close(); process.WaitForExit(); return process.ExitCode; } }