A
A
Alexander Antonov2015-11-13 22:28:34
C++ / C#
Alexander Antonov, 2015-11-13 22:28:34

How to get normal console output?

cmdProcess = new Process();

var procStartInfo =
  new ProcessStartInfo( "cmd", "/k " );

procStartInfo.RedirectStandardOutput    = true;
procStartInfo.RedirectStandardInput     = true;
procStartInfo.UseShellExecute           = false;
procStartInfo.WindowStyle               = System.Diagnostics.ProcessWindowStyle.Hidden;

procStartInfo.CreateNoWindow = true;

cmdProcess.OutputDataReceived += ( s, e ) => {
  Console.WriteLine( e.Data + "\n" );
};

cmdProcess.StartInfo = procStartInfo;

cmdProcess.Start();
cmdProcess.BeginOutputReadLine();

This code returns output only when the line breaks.
How can I get real-time output, for example from programs like Far Manager?
I most likely need a so-called. screen buffer or something like that
And another question, how can I send CTRL+C to such a console process?
cmdProcess.StandardInput.Write( msg );
Such code will wait for the end of the command output, and I need this to be done asynchronously.
I will be glad to examples, links, manuals.
Thanks in advance!

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question