Try the following if you just want to have the window in your own program:
[highlight="VB.NET"]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
WindowToPanel("C:\Dokumente und Einstellungen\Xerxes\Desktop\random.bat", Panel1)
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
[/highlight]
If you need to know what's in the cmd window listen to the guys below.
