Send output to stdout from gui app...possible?

I have a simple vb.net gui application (an alternative file requester in a form) that I would like to run from the command line. It executes fine, but I find that I cannot send any output (a string representing the file selected) to the command line upon completion. It appears that "console.writeline" doesn't actually write to the console? Any suggestions as to how to send info back to the console window upon completion? Keep in mind that this is a gui app (not straight console).
[495 byte] By [smarrocco] at [2007-12-24]
# 1

Dim Si As New ProcessStartInfo

Dim P As New Process

P.StartInfo = Si

Si.FileName = ("MyExePath")

Si.UseShellExecute = False

Si.RedirectStandardOutput = True

P.Start()

Console.WriteLine(P.StandardOutput.ReadToEnd())

P.WaitForExit()

DMan1 at 2007-8-31 > top of Msdn Tech,Visual Basic,Visual Basic General...
# 2

so you have a GUI winform app but want to run it from the command line correct? and any outputs you want made from your GUI app you wish to see it on the Command line (MSDOS) window correct?

Well, the above solution from DMan1 will not work as the solution would work if you are executing a 3rd party app outside of your application - which is not what you would like from your description

The Console.Write() or System.Diagnostics.Debug.Write() will work within the IDE output Window.

I am unsure how you would write to the MSDOS window within a WinForm app (GUI) however you could give the Console a streamwriter to write to a textfile for example in this case if it helps?

if you go to your project properties in the "Application" tab, if you set the "output type" to Console Application, this will/should write your output to the console window as well as running your winform app

does this help?

ahmedilyas at 2007-8-31 > top of Msdn Tech,Visual Basic,Visual Basic General...
# 3

Dim ins As System.IO.Stream = System.Console.OpenStandardOutput()

Dim os As System.IO.Stream = System.Console.OpenStandardInput()

ReneeC at 2007-8-31 > top of Msdn Tech,Visual Basic,Visual Basic General...
# 4
that doesnt work ReneeC, I also tried that
ahmedilyas at 2007-8-31 > top of Msdn Tech,Visual Basic,Visual Basic General...
# 5

I instantiated that streams and received valid streams although, the second was a null stream.

There is abother approach.

You begin with a console task and add forms capability as shown here:

http://www.geocities.com/Jeff_Louie/multi-threaded.htm

ReneeC at 2007-8-31 > top of Msdn Tech,Visual Basic,Visual Basic General...
# 6
thanks for that, or you could right click the project > properties. Set the "output type" to Console Application, and accept the changes. inputs and outputs will be directed to the MS DOS Window if ran from it.
ahmedilyas at 2007-8-31 > top of Msdn Tech,Visual Basic,Visual Basic General...
# 7
I tried the changing of the output type to "console Application". Unfortunately, this disables the gui (which then never appears) although the test does output to the console shell.

It seems as though it can be a gui app, or a console app, but not both so far......

smarrocco at 2007-8-31 > top of Msdn Tech,Visual Basic,Visual Basic General...
# 8
really? you sure? as I have just tried it before posting and it shows me both! the GUI and the output to the console app.
ahmedilyas at 2007-8-31 > top of Msdn Tech,Visual Basic,Visual Basic General...
# 9

No, it's not "Output type" it's Application Type. Running such an application brings up a command window and a form in classic styling.

"Outputs" to say textbox1.text still go to textbox1.text.

I think the OP needs to define what inputs and outputs are being referred to and so do you.

ReneeC at 2007-8-31 > top of Msdn Tech,Visual Basic,Visual Basic General...
# 10

just did this video for you:

http://www.spapps.co.uk/msdn/forums/vids/ConsoleGUI.wmv

http://www.ai2005.pwp.blueyonder.co.uk/ConsoleGUI.wmv - if the above link doesnt work

ahmedilyas at 2007-8-31 > top of Msdn Tech,Visual Basic,Visual Basic General...
# 11
I was mistaken, ahmedilyas, that did the trick. I made a test app and it worked perfectly. Not sure what exactly switching the app type to "console" does, but it worked. My thanks to you and everyone who contributed.

Apparently flipping the app type like that lets the gui app to run normally (as near as I can tell). The only down side is that, if run from an icon (non-console) the app pops open a shell window. Since this app will only be run from a command line, that shouldn't be a problem.

smarrocco at 2007-8-31 > top of Msdn Tech,Visual Basic,Visual Basic General...
# 12
glad I could help!
ahmedilyas at 2007-8-31 > top of Msdn Tech,Visual Basic,Visual Basic General...
# 13

Hi,

Well... Guess what... does that also work in Visual Studio 2005? Being a novice to VS2005, I can not get it to work! Very frustrated... Many, many years of programming experience in C... and now, in VS2005 and C++, I can not get anything on the standard output, in combination with a GUI application...

Please help.

Matthijs.

Matthijs_1971 at 2007-8-31 > top of Msdn Tech,Visual Basic,Visual Basic General...