Skip to content

Getting back output from command process?

Chris

Asked Apr 17, 2007, 10:49 AM EDT1 answer
Share
LinkedInX
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); } }

1 Answer

Know the answer? Post it. Somebody with the same question will find it here.

  • Mike Gold
    0
    Check this example on MSDN on reading standard output:
    0