471,605 Members | 1,623 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,605 software developers and data experts.

DOS exe output?

Hi, I have a small dos program that compiles txt files. The dos program
checks the text file, and if there's an error or if the text is ok it
sends a message to the dos prompt. I would like to capture this message
and display it in a textbox. I have already tried with the code below,
but i don't get the output from the text compler program, but I do get
some DOS output like the path the program is in etc. Does anybody know
how to solve this problem????

System.Diagnostics.Process p2 = new System.Diagnostics.Process();
StreamWriter sw2;
StreamReader sr2;
StreamReader err2;
System.Diagnostics.ProcessStartInfo psI2 = new
System.Diagnostics.ProcessStartInfo("POINT");
psI2.UseShellExecute = false;
psI2.RedirectStandardInput = true;
psI2.RedirectStandardOutput = true;
psI2.RedirectStandardError = true;
psI2.CreateNoWindow = true;
psI2.Arguments = "/K" + compileTextFile;
p2.StartInfo = psI2;
p2.Start();
sw2 = p2.StandardInput;
sr2 = p2.StandardOutput;
err2 = p2.StandardError;
textBox1.Text = sr2;

Thanks!

Feb 10 '06 #1
1 2060
AxOn wrote:
Hi, I have a small dos program that compiles txt files. The dos program
checks the text file, and if there's an error or if the text is ok it
sends a message to the dos prompt. I would like to capture this message
and display it in a textbox. I have already tried with the code below,
but i don't get the output from the text compler program, but I do get
some DOS output like the path the program is in etc. Does anybody know
how to solve this problem????


You can't just assign the Text property of a TextBox to be a
StreamReader. Instead, you need to read from stdout/stderr, and take
appropriate action when you read something. Note that in order to avoid
deadlocks where the process runs out of output buffering, it's worth
doing the reading on different threads. (As always, make sure that the
bit of code which updates the UI uses Control.Invoke/BeginInvoke to get
to the UI thread.)

Jon

Feb 10 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by Mark Wilson CPU | last post: by
3 posts views Thread by edgekaos | last post: by
4 posts views Thread by Kevin Mansel via .NET 247 | last post: by
24 posts views Thread by kalamantina | last post: by
reply views Thread by newbie | last post: by
3 posts views Thread by MatsL | last post: by
5 posts views Thread by amit.uttam | last post: by
1 post views Thread by XIAOLAOHU | last post: by
reply views Thread by MichaelMortimer | last post: by
reply views Thread by CCCYYYY | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.