Chris

Chris

  • NA
  • 11
  • 0

Getting back output from command process?

Apr 17 2007 2:49 PM
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); } }

Answers (1)