Sorry to answer myself...
I've worked at little more on my previously posted examples.
Test before using.
------------Example 1----------------
using System;
using System.IO;
using System.Diagnostics;
using System.ComponentModel;
class test{
static void Main()
{
System.Diagnostics.Process myProcess = new System.Diagnostics.Process();
myProcess.StartInfo.FileName = "systeminfo";
myProcess.StartInfo.UseShellExecute = false;
myProcess.StartInfo.CreateNoWindow = false;
myProcess.StartInfo.RedirectStandardInput = true;
myProcess.StartInfo.RedirectStandardOutput = true;
myProcess.StartInfo.RedirectStandardError = true;
myProcess.Start();
StreamWriter sIn = myProcess.StandardInput;
StreamReader sOut = myProcess.StandardOutput;
StreamReader sErr = myProcess.StandardError;
string s = sOut.ReadToEnd();
Console.WriteLine(s);
sIn.Close();
sOut.Close();
myProcess.Close();
}
}
-----------end example1------------
-----------Example 2----------------
using System;
using System.IO;
using System.Diagnostics;
using System.ComponentModel;
class test{
static void Main()
{
System.Diagnostics.Process myProcess = new System.Diagnostics.Process();
myProcess.StartInfo.FileName = "cmd.exe";
myProcess.StartInfo.UseShellExecute = false;
myProcess.StartInfo.CreateNoWindow = false;
myProcess.StartInfo.RedirectStandardInput = true;
myProcess.StartInfo.RedirectStandardOutput = true;
myProcess.StartInfo.RedirectStandardError = true;
myProcess.Start();
StreamWriter sIn = myProcess.StandardInput;
StreamReader sOut = myProcess.StandardOutput;
StreamReader sErr = myProcess.StandardError;
sIn.WriteLine("systeminfo");
sIn.WriteLine("exit");
//myProcess.WaitForExit(); -- This hangs the program
string s = sOut.ReadToEnd();
Console.WriteLine(s);
sIn.Close();
sOut.Close();
myProcess.Close();
}
}
---------end example 2--------------