On Jan 11, 4:31 am, Paulers <SuperG...@gmail.comwrote:
Hello,
I am trying to manipulate a console based application from another
application for example I need to launch the console application,
provide it input and take the output from the console application and
use it within my application. Is this possible with vb.net? If so
could someone point me in the right direction. Thank you :)
You can redirect command prompt's output to an Win32 app's object
within your project:
Here is a sample returns "dir" command prompt result into a textbox:
Place a textbox(textbox1) and a button(button1) for these
demonstration:
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles Button1.Click
Dim start_info As New ProcessStartInfo("cmd.exe", "/c dir")
start_info.UseShellExecute = False
start_info.CreateNoWindow = True
start_info.RedirectStandardOutput = True
start_info.RedirectStandardError = True
' Make the process and set its start information.
Dim proc As New Process()
proc.StartInfo = start_info
' Start the process.
proc.Start()
' Attach to stdout and stderr.
Dim std_out As IO.StreamReader = proc.StandardOutput()
' Display the results.
TextBox1.Text = std_out.ReadToEnd()
' Clean up.
std_out.Close()
proc.Close()
End Sub
End Class
Hope this helps.