Execute an .exe and get the output returned by an .exe

System.Diagnostics.Process myProcess = new System.Diagnostics.Process();
myProcess.StartInfo.FileName = "C:\\MyExe.exe";
myProcess.StartInfo.UseShellExecute = false;
myProcess.StartInfo.CreateNoWindow = false;
myProcess.StartInfo.RedirectStandardInput = false;
myProcess.StartInfo.RedirectStandardOutput = true;
myProcess.StartInfo.RedirectStandardError = true;
myProcess.Start();

StreamReader sOut = myProcess.StandardOutput;
StreamReader sErr = myProcess.StandardError;

myProcess.WaitForExit();
string output = sOut.ReadToEnd();

textBox1.Text = output;

Comments

Popular posts from this blog

Convert XElement to DataTable

Enable mouse scroll-wheel in VB6

C# code to Check IE Proxy Settings