title: Run or Embed VB.NET console application within a VB.NET or C# forms application
body: <p>I have a bunch of related VB.NET console applications I've written for admin/management functions.</p>
  
  <p>I now want to bring them together under a single Windows Forms application that works as a launcher, but instead of launching the apps as seperate programs, I want to embed the apps in the windows forms app, e.g. have a scrollable list of icons down the left hand side - clicking on one will launch the associated .exe in the right hand pane of the windows forms app.</p>
  
  <p>For now I have a simple single form application with one panel, so I can test out if what I want to do is possible.</p>
  
  <p>Having read around MSDN and SO, I've found other posts about this but none that seem to do what I want.</p>
  
  <p>I don't want to intercept stin/stdout/stderr streams and attempt to emulate the console application, I want to actually run the compiled exe (which I can achieve) but have it run inside the windows form (which I can't achieve, it launches as a seperate process).</p>
  
  <p>The main code for Form1 that I have right now is:</p>
  
  <pre><code>Public Class Form1
  Declare Auto Function SetParent Lib "user32.dll" (ByVal hWndChild As IntPtr, ByVal hWndNewParent As IntPtr) As Integer
  Declare Auto Function SendMessage Lib "user32.dll" (ByVal hWnd As IntPtr, ByVal Msg As Integer, ByVal wParam As Integer, ByVal lParam As Integer) As Integer
  Private Const WM_SYSCOMMAND As Integer = 274
  Private Const SC_MAXIMIZE As Integer = 61488
  Dim proc As Process
  
  Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
      proc = Process.Start("\\fileserver\datashare\path\WIN_MGR.exe")
      proc.WaitForInputIdle()
      SetParent(proc.MainWindowHandle, Me.Panel1.Handle)
      SendMessage(proc.MainWindowHandle, WM_SYSCOMMAND, SC_MAXIMIZE, 0)
  End Sub
  
  End Class
  </code></pre>
  
  <p>Anyone able to put me in the right direction to actually run the .exe application windowed within the windows form?</p>