Module1.vb
----------

Option Strict Off
Option Explicit On
Module Module1
	
	Public Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess As Integer, ByVal bInheritHandle As Integer, ByVal dwProcessId As Integer) As Integer
	Public Declare Function GetExitCodeProcess Lib "kernel32" (ByVal hProcess As Integer, ByRef lpExitCode As Integer) As Integer
	Public Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Integer) As Integer
	
	Private Const PROCESS_INFO As Integer = &H400
	Private Const STILL_RUNNING As Integer = &H103
	

	Public Sub RunShell(ByRef exe_and_batchstring As String)
		
		Dim hProcess As Integer
		Dim ProcessId As Integer
		Dim exitCode As Integer
		Dim StrExitCode As String
		
		ProcessId = Shell(exe_and_batchstring, 1)
		hProcess = OpenProcess(PROCESS_INFO, False, ProcessId)
		
		Do 
			Call GetExitCodeProcess(hProcess, exitCode)
			System.Windows.Forms.Application.DoEvents()
		Loop While exitCode = STILL_RUNNING
		StrExitCode = CStr(exitCode)
		
		Call CloseHandle(hProcess)
		Form1.txtResult.Text = StrExitCode ' Show the exitcode on the form ...
		
		'   MsgBox exe_and_batchstring & " ... ends with exitcode: " & StrExitCode
		
	End Sub
End Module

frmTest.vb
----------

Option Strict Off
Option Explicit On
Friend Class Form1
	Inherits System.Windows.Forms.Form
	
	Private Sub cmdFunk_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles cmdFunk.Click
		
		RunShell(txtexe.Text & " " & txtbatch.Text)
		
	End Sub
End Class

Aus frmTest.Designer.vb
-----------------------

...
Me.txtexe.Text = """c:\temp\unlock_ald.exe"" "
...
Me.txtbatch.Text = """c:\temp\form.pdf"" 1"
...



