Module1.cs
----------

using Microsoft.VisualBasic;
using Microsoft.VisualBasic.Compatibility;
using System;
using System.Collections;
using System.Data;
using System.Diagnostics;
using System.Drawing;
using System.Windows.Forms;
using System.Runtime.InteropServices;

namespace Projekt1
{
	static class Module1
	{
		[DllImport("kernel32", CharSet = CharSet.Ansi, SetLastError = true, ExactSpelling = true)]

		public static extern int OpenProcess(int dwDesiredAccess, int bInheritHandle, int dwProcessId);
		[DllImport("kernel32", CharSet = CharSet.Ansi, SetLastError = true, ExactSpelling = true)]
		public static extern int GetExitCodeProcess(int hProcess, ref int lpExitCode);
		[DllImport("kernel32", CharSet = CharSet.Ansi, SetLastError = true, ExactSpelling = true)]
		public static extern int CloseHandle(int hObject);

		private const int PROCESS_INFO = 0x400;
		private const int STILL_RUNNING = 0x103;


		public static void RunShell(ref string exe_and_batchstring)
		{

			int hProcess = 0;
			int ProcessId = 0;
			int exitCode = 0;
			string StrExitCode = "";

            ProcessId = Interaction.Shell(exe_and_batchstring, AppWinStyle.NormalFocus, false, -1);
			hProcess = OpenProcess(PROCESS_INFO, 0, ProcessId);

			do {
				GetExitCodeProcess(hProcess, ref exitCode);
				System.Windows.Forms.Application.DoEvents();
			} while (exitCode == STILL_RUNNING);
			StrExitCode = Convert.ToString(exitCode);

			CloseHandle(hProcess);
            // My.MyProject.Forms.Form1.txtResult.Text = StrExitCode;
			// Show the exitcode on the form ...

            MessageBox.Show(StrExitCode);

		}
	}
}

frmTest.cs
----------

using Microsoft.VisualBasic;
using Microsoft.VisualBasic.Compatibility;
using System;
using System.Collections;
using System.Data;
using System.Diagnostics;
using System.Drawing;
using System.Windows.Forms;

namespace Projekt1
{
	internal partial class frmTest : System.Windows.Forms.Form
	{

		private void cmdFunk_Click(System.Object eventSender, System.EventArgs eventArgs)
		{
            
            string batchline = txtexe.Text + " " + txtbatch.Text;
			Module1.RunShell(ref batchline);

           
		}
	}
}

frmTest.Designer.cs
-------------------

using Microsoft.VisualBasic;
using Microsoft.VisualBasic.Compatibility;
using System;
using System.Collections;
using System.Data;
using System.Diagnostics;
using System.Drawing;
using System.Windows.Forms;
namespace Projekt1
{
	[Microsoft.VisualBasic.CompilerServices.DesignerGenerated()]
	partial class frmTest
	{

        [STAThread]
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new frmTest());
        }

		#region "Vom Windows Form-Designer generierter Code "
		[System.Diagnostics.DebuggerNonUserCode()]
		public frmTest() : base()
		{
			//Dieser Aufruf ist für den Windows Form-Designer erforderlich.
			InitializeComponent();
		}
//Das Formular überschreibt den Löschvorgang, um die Komponentenliste zu bereinigen.
		[System.Diagnostics.DebuggerNonUserCode()]
		protected override void Dispose(bool Disposing)
		{
			if (Disposing) {
				if ((components != null)) {
					components.Dispose();
				}
			}
			base.Dispose(Disposing);
		}
//Wird vom Windows Form-Designer benötigt.
		private System.ComponentModel.IContainer components;
		public System.Windows.Forms.ToolTip ToolTip1;
		public System.Windows.Forms.TextBox txtbatch;
		public System.Windows.Forms.TextBox txtexe;
		private System.Windows.Forms.Button withEventsField_cmdFunk;
		public System.Windows.Forms.Button cmdFunk {
			get { return withEventsField_cmdFunk; }
			set {
				if (withEventsField_cmdFunk != null) {
					withEventsField_cmdFunk.Click -= cmdFunk_Click;
				}
				withEventsField_cmdFunk = value;
				if (withEventsField_cmdFunk != null) {
					withEventsField_cmdFunk.Click += cmdFunk_Click;
				}
			}
		}
		public System.Windows.Forms.Label Label2;
		public System.Windows.Forms.Label Label1;
//Hinweis: Die folgende Prozedur ist für den Windows Form-Designer erforderlich.
//Das Verändern mit dem Windows Form-Designer ist nicht möglich.
//Das Bearbeiten mit dem Code-Editor ist nicht möglich.
		[System.Diagnostics.DebuggerStepThrough()]
		private void InitializeComponent()
		{
                        // ...
			//
			//txtbatch
			//
			this.txtbatch.AcceptsReturn = true;
			this.txtbatch.BackColor = System.Drawing.SystemColors.Window;
			this.txtbatch.Cursor = System.Windows.Forms.Cursors.IBeam;
			this.txtbatch.ForeColor = System.Drawing.SystemColors.WindowText;
			this.txtbatch.Location = new System.Drawing.Point(112, 40);
			this.txtbatch.MaxLength = 0;
			this.txtbatch.Name = "txtbatch";
			this.txtbatch.RightToLeft = System.Windows.Forms.RightToLeft.No;
			this.txtbatch.Size = new System.Drawing.Size(401, 25);
			this.txtbatch.TabIndex = 3;
			this.txtbatch.Text = "\"c:\\temp\\form.pdf\" 1";
			//
			//txtexe
			//
			this.txtexe.AcceptsReturn = true;
			this.txtexe.BackColor = System.Drawing.SystemColors.Window;
			this.txtexe.Cursor = System.Windows.Forms.Cursors.IBeam;
			this.txtexe.ForeColor = System.Drawing.SystemColors.WindowText;
			this.txtexe.Location = new System.Drawing.Point(112, 8);
			this.txtexe.MaxLength = 0;
			this.txtexe.Name = "txtexe";
			this.txtexe.RightToLeft = System.Windows.Forms.RightToLeft.No;
			this.txtexe.Size = new System.Drawing.Size(401, 25);
			this.txtexe.TabIndex = 1;
			this.txtexe.Text = "\"c:\\temp\\unlock_ald.exe\" ";
			//
			//cmdFunk
			//
			this.cmdFunk.BackColor = System.Drawing.SystemColors.Control;
			this.cmdFunk.Cursor = System.Windows.Forms.Cursors.Default;
			this.cmdFunk.ForeColor = System.Drawing.SystemColors.ControlText;
			this.cmdFunk.Location = new System.Drawing.Point(8, 80);
			this.cmdFunk.Name = "cmdFunk";
			this.cmdFunk.RightToLeft = System.Windows.Forms.RightToLeft.No;
			this.cmdFunk.Size = new System.Drawing.Size(409, 25);
			this.cmdFunk.TabIndex = 0;
			this.cmdFunk.Text = "Starting the process ... and wait for the result";
			this.cmdFunk.UseVisualStyleBackColor = false;
			//
			//Label2
			//
                        // ...
		}
		#endregion
	}
}


