Что то старое было:
System.Diagnostics.Process p = new System.Diagnostics.Process();
p.StartInfo.UseShellExecute = false;
p.StartInfo.FileName = "cmd.exe";
p.StartInfo.RedirectStandardError = true;
p.StartInfo.RedirectStandardInput = true;
p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.CreateNoWindow = true;
//p.StartInfo.StandardOutputEncoding = System.Text.Encoding.UTF8;
int lcid = GetSystemDefaultLCID();
var ci = System.Globalization.CultureInfo.GetCultureInfo(lcid);
var page = ci.TextInfo.OEMCodePage;
p.StartInfo.StandardOutputEncoding = Encoding.GetEncoding(page);
p.Start();
try
{
p.BeginOutputReadLine();
p.BeginErrorReadLine();
p.StandardInput.AutoFlush = true;
p.OutputDataReceived += (s, e) => { ... }
p.ErrorDataReceived += (s, er) => { ... }
while (true)
{ // "\x3" - Ctrl+C
if (p.HasExited == true) { break; }
p.StandardInput.WriteLine( ... );
}
}
catch (Exception)
{
...
}