void LaunchProcessButton_Click (object sender, EventArgs e)
{
string systemDir = Environment.GetFolderPath (Environment.SpecialFolder.System);
string exe = Path.Combine (systemDir, "notepad.exe");
Process p = new Process ();
p.StartInfo = new ProcessStartInfo ();
p.StartInfo.FileName = exe;
p.StartInfo.UseShellExecute = _useShellExecuteCheckBox.Checked;
p.StartInfo.WindowStyle = (ProcessWindowStyle)
_windowStyleListBox.SelectedValue;
p.Start ();
if (p.WaitForExit (1000))
throw new Exception ("Process has exited!");
p.Kill ();
Thread.Sleep (200);
if (!p.HasExited)
throw new Exception ("Process could not be stopped!");
}