Displaying Command Prompt on Windows Forms

Hi,
we currently have console application that has to be integrated into our newer Winforms application. The output should be displayed on the Windows Form. What is the simplest solution with the minimum amount of digging into the code?
Any ideas? Is there some kind of command prompt control where the command prompt window can be displayed?
Thanks.
quasar_eeAsked:
Who is Participating?
 
Paul_Harris_FusionCommented:
You could redirect the standard output from the process that runs your command line and post it on your form.

I think a bit of searding onr redirect stdout would turn up lots of examples
One such here...
http://www.devx.com/dotnet/Article/7914/0/page/5
0
 
Paul_Harris_FusionCommented:
Sorry - example was vb.net but I;m sure you get the idea.....
0
 
käµfm³d 👽Commented:
You could launch the console application via System.Diagnostics.Process, redirect the output, then capture and display that output in a textbox. Here's a C# example:
System.Diagnostics.ProcessStartInfo info = new System.Diagnostics.ProcessStartInfo();

info.FileName = @"C:\path\to\console\app.exe";
info.Arguments = "argumen1 argument2";
info.UseShellExecute = false;
info.RedirectStandardOutput = true;

System.Diagnostics.Process p = System.Diagnostics.Process.Start(info);
p.WaitForExit();

this.textBox1.Text = p.StandardOutput.ReadToEnd();

Open in new window

0
Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

 
CodeCruiserCommented:
How about hosting the console in your winforms?

http://www.codeproject.com/KB/miscctrl/AppControl.aspx
0
 
käµfm³d 👽Commented:
How about hosting the console in your winforms?
For that approach, you'll have to change the call to WaitForInputIdle() to a Sleep() call (or some other mechanism which will give the process enough time to acquire its window handle). Console applications don't have a message pump like forms apps do, and WaitForInputIdle is dependent on a message pump.
0
 
Rose BabuSenior Team ManagerCommented:
Hi,

here is  a sample projects for command prompt custom cotrol.

this may help you.

http://www.codeproject.com/KB/miscctrl/commandprompt.aspx
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.