Getting back output from command process?
Hey guys, I am successfully calling/executing an .exe file through the commandline but do not know how to grab the output it generates so that I can display in my GUI. Currently it does not display any of the output it needs to be.
Thanks for any help! - Chris
Here's my code:
------------------
public void StartMessageServer(string queueManager)
{
StringBuilder strCommand = new StringBuilder();
strCommand.Append(queueManager);
try
{
Process cmd = new Process();
cmd.StartInfo.FileName = @"C:\Program Files\IBM\WebSphere MQ\bin\strmqm.exe";
cmd.StartInfo.Arguments = strCommand.ToString();
cmd.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
cmd.StartInfo.UseShellExecute = false;
cmd.StartInfo.RedirectStandardOutput = true;
cmd.Start();
PublisherUtils.WriteText(cmd.StandardOutput.ReadToEnd(), this.OutputListBox);
cmd.WaitForExit(5000);
cmd.Close();
}
catch(Exception ex)
{
PublisherUtils.WriteText(ex.Message, this.OutputListBox);
}
}