





Dim Processo As New Process
Dim ProcInfo As New ProcessStartInfo(YOUR PROCESS, PROCESS ATRIBUTES )
Processo.StartInfo = ProcInfo
ProcInfo.UseShellExecute = False
ProcInfo.RedirectStandardError = True
ProcInfo.RedirectStandardInput = True
ProcInfo.RedirectStandardOutput = True
Processo.Start()
Dim CMDString As New StringBuilder
Dim ReadingCMDString As IO.StreamReader = Processo.StandardOutput
While Not ReadingCMDString.EndOfStream
Dim Line As String = ReadingCMDString.ReadLine
Try
If Not Line = vbNullString Then
CMDString.AppendLine(Trim(Line))
End If
Catch ex As Exception
End Try
End While
ReadingCMDString.Close()
Processo.WaitForExit(1)
TextBox1.Text = CMDString.ToString
Catch ex As Exception
End Try


i dont need it to star only type in the text that the cmd is typing. and once it acctualy is open nothing happens in the cmd.? this is my code Private Sub OpenFileDialog1_FileOk(ByVal sender As System.Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles OpenFileDialog1.FileOk
TextBox3.Text = OpenFileDialog1.FileName
Dim Processo As New Process
Dim ProcInfo As New ProcessStartInfo(TextBox3.Text)
Processo.StartInfo = ProcInfo
ProcInfo.UseShellExecute = False
ProcInfo.RedirectStandardError = True
ProcInfo.RedirectStandardInput = True
ProcInfo.RedirectStandardOutput = True
Processo.Start()
Dim CMDString As New StringBuilder
Dim ReadingCMDString As IO.StreamReader = Processo.StandardOutput
While Not ReadingCMDString.EndOfStream
Dim Line As String = ReadingCMDString.ReadLine
Try
If Not Line = vbNullString Then
CMDString.AppendLine(Trim(Line))
End If
Catch ex As Exception
End Try
End While
ReadingCMDString.Close()
Processo.WaitForExit(1)
Try
TextBox1.Text = CMDString.ToString
Catch ex As Exception
End Try
End Sub

Imports System****ntime.InteropServices
Imports System.IO
Public Class Form1
#Region "DLLImports"
<DllImport("user32.dll", SetLastError:=True, CharSet:=CharSet.Auto)> _
Private Shared Function ShowWindow(ByVal hWnd As IntPtr, ByVal nCmdShow As Integer) As Boolean
End Function
<DllImport("user32.dll", SetLastError:=True, CharSet:=CharSet.Auto)> _
Private Shared Function SetParent(ByVal hWndChild As IntPtr, ByVal hWndNewParent As IntPtr) As IntPtr
End Function
<DllImport("user32.dll")> _
Private Shared Function SetWindowLong(ByVal hWnd As IntPtr, ByVal nIndex As Short, ByVal dwNewLong As Integer) As Integer
End Function
<DllImport("user32.dll")> _
Private Shared Function GetWindowLong(ByVal hWnd As IntPtr, ByVal nIndex As Integer) As Integer
End Function
Const SW_MAXIMIZE As Integer = 3
Const GWL_STYLE As Integer = -16
#End Region
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
End Sub
Dim pProcess As New System.Diagnostics.Process
Private Sub WindowToPanel(ByVal Filepath As String, ByVal Panel As Panel)
Panel.Visible = False
Try
pProcess.StartInfo.FileName = Filepath
pProcess.StartInfo.WorkingDirectory = Path.GetDirectoryName(Filepath)
pProcess.StartInfo.WindowStyle = ProcessWindowStyle.Minimized
pProcess.Start()
SetParent(pProcess.MainWindowHandle, Panel.Handle)
ShowWindow(pProcess.MainWindowHandle, SW_MAXIMIZE)
Dim frm As Integer = GetWindowLong(pProcess.MainWindowHandle, GWL_STYLE)
SetWindowLong(pProcess.MainWindowHandle, GWL_STYLE, frm And Not 12582912)
Panel.Visible = True
Catch ex As Exception
MessageBox.Show(ex.Message.ToString(), "Info")
End Try
Panel1.Visible = True
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
OpenFileDialog1.ShowDialog()
End Sub
Private Sub OpenFileDialog1_FileOk(ByVal sender As System.Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles OpenFileDialog1.FileOk
TextBox1.Text = OpenFileDialog1.FileName
WindowToPanel(TextBox1.Text, Panel1)
End Sub
End Class

TextBox1.Text = readProcessOutput(Environment.GetFolderPath(Environment.SpecialFolder.Desktop) & "\test.bat")