Is it possible to write to the windows dos screen and display the results in a GUI?




            for (int i = 0; i < 5; i++)
                textBox1.Text = Console.ReadLine().ToString();     
6 Years
Discussion Span
Last Post by Diamonddrake

The method I will use to acheive this is, by making a batch file.
You can create a batch file from your program, the only difference is it ends with a ".bat", rest it is just a text file which contains the commands you want to enter in DOS. And in order to solve the GUI problem what I can think of is writing the output to a textfile and then reading the string into the textbox of the GUI. Hope this helps.

Edited by Software guy: n/a


Another way to do this is start a new windows application, then go into the properties and switch it to a command line application. This gives you both a window and a command box.


I found a way of doing this by writing a batch file and executing it within the GUI by using the code;

proc.StartInfo.FileName = "@FILENAME"

I then saved the result by using;

> output.txt"

at the end of my command in the batch file and then I could view the results within the GUI by reading the txt file that was created.


Honestly your solution is totally backwoods.

If you create a new process you can redirect its standard output to a stream, then do whatever you want with it. ex.

CurrentProcess = new Process();
CurrentProcess.StartInfo.FileName = exepath;
CurrentProcess.StartInfo.UseShellExecute = false;
CurrentProcess.StartInfo.CreateNoWindow = true;
CurrentProcess.StartInfo.RedirectStandardOutput = true;
CurrentProcess.StartInfo.RedirectStandardInput = true;
CurrentProcess.StartInfo.RedirectStandardError = true;

CurrentProcess.StandardOutput; will return a stream reader object that you can use to do anything you want with the output, for example write it to a text box.

You don't have to resort to a temp file.

Attached is an example of GUI based console, its just as completely basic as it could be, I encourage you to use this method over using the disk.

Edited by Diamonddrake: n/a

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.