Reputation: 2156
using this Code
Process process = new Process();
// p.EnableRaisingEvents = true;
process.EnableRaisingEvents = true;
process.OutputDataReceived += new DataReceivedEventHandler(p_OutputDataReceived);
process.StartInfo.RedirectStandardOutput = true;
process.StartInfo.CreateNoWindow = true;
process.StartInfo.LoadUserProfile = false;
process.StartInfo.UseShellExecute = false;
process.StartInfo.FileName = @"C:\putty.exe"; ; // Gets or sets the application or document to start.
process.StartInfo.Arguments = "-serial com31 -sercfg 9600,8,n,1,N";//Gets or sets the set of command-line arguments to use when starting the application
Thread.Sleep(1000);
process.Start();//Starts (or reuses) the process resource that is specified by the StartInfo property of this Process component and associates it with the component.
process.BeginOutputReadLine();
process.WaitForExit(); // wait forever with ping
I'm trying to open putty in console application , but any timr I use it it opens in New windows and I cant get to output of the process using process.OutputDataReceived
event
I'm using code very similar to this to open Iperf
and it works fine
What am I missing here ?
Upvotes: 1
Views: 1461
Reputation: 1418
Putty
is not a console application
and therefore does not provide output on it's stdout
and stderr
streams.
And since it is a windowed application
it does not care whether you start it with the CreateNoWindow
flag. Try and start notepad.exe
with that flag, you will see it appearing obviously.
There is however a programm by the creators of Putty
that provides the functionality you need.
It's called Plink.exe
and you can download it on their homepage
Upvotes: 4