Process p = null;try { // Start the processp = System.Diagnostics.Process.Start(this.exeName); // Wait for process to be created and enter idle conditionp.WaitForInputIdle(); // Get the main handle appWin = p.MainWindowHandle;}catch (Exception ex){MessageBox.Show(this, ex.Message, "Error");}