getting output of a console application

jorge

Well-known member
Joined
Jul 13, 2003
Messages
239
Location
Belgium
Hello,
I it posible to get the output of a console application?
if yes any pointer on how to do it?
 
yes, sry thah i didnt explean mysellf clearly(sry happen a lot :( )
I have a application and i call:
pacth to exe/apache.exe -t,
it open a command windows with the text syntax ok, or a error msg if somthing is wrong, instead of showing the command windows i would like to put the information into a textbox.
 
The ProcessStartInfo class will provide you with an option to get the output from a console app. Then you can pass in the ProcessStartInfo class into the Process.Start method.
Code:
Dim pi As New ProcessStartInfo("cmd.exe")
pi.RedirectStandardOutput = True
pi.UseShellExecute = False required call to redirect streams
Dim p As Process = p.Start(pi)
p.WaitForExit()
MessageBox.Show(p.StandardOutput.ReadToEnd()) show what the application tried to print onto the console
Now this will get all the text that the application would normally print ou to the console and put into the stream instead, thus nothing will print on the console itself.
 
ok i pass /k apache -t to cmd.exe,
but it only returns:
Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.

C:\Documents and Settings\Jorge Schrauwen\Desktop\pluginexample\WindowsApplication1\bin>
C:\Documents and Settings\Jorge Schrauwen\Desktop\pluginexample\WindowsApplication1\bin>
instead of systax ok,
and nothing when i start apache.exe instread of cmd and pass the argument "-t"
 
Back
Top