/// <summary> /// Runs the Install, for the specified options. /// Required info as per Windows command prompt execution methods. /// </summary> /// <param name="processInfo">Parameters to with the required info to run the install.</param> /// <returns></returns> private static InstallResult RunProcess(ProcessStartInfo processInfo) { var result = new InstallResult(); // The following WindowsUninstaller.WindowsExitCode used below might be Windows specific. // Third party apps might not use same code. Good luck! try { using (var process = Process.Start(processInfo)) { process.WaitForExit(); result.ExitCode = process.ExitCode; result.ExitCodeMessage = new Win32Exception(process.ExitCode).Message; switch (result.ExitCode) { case (int)WindowsUninstaller.WindowsExitCode.Restart: case (int)WindowsUninstaller.WindowsExitCode.Reboot: result.Restart = true; result.Success = true; break; case (int)WindowsUninstaller.WindowsExitCode.Sucessful: result.Success = true; break; default: result.Success = false; break; } var output = process.StandardOutput; result.Output = output.ReadToEnd(); } return(result); } catch (Exception e) { Logger.Log("Custom App Installer failed to install: {0}.", LogLevel.Error, processInfo.FileName); Logger.LogException(e); result.ExitCode = -1; result.ExitCodeMessage = String.Format("Custom App Installer failed to install {0}.", processInfo.FileName); result.Output = String.Empty; result.Restart = false; result.Success = false; return(result); } }
/// <summary> /// Runs the Install, for the specified options. /// Required info as per Windows command prompt execution methods. /// </summary> /// <param name="processInfo">Parameters to with the required info to run the install.</param> /// <returns></returns> private static InstallResult RunProcess(ProcessStartInfo processInfo) { var result = new InstallResult(); // The following WindowsUninstaller.WindowsExitCode used below might be Windows specific. // Third party apps might not use same code. Good luck! try { using (var process = Process.Start(processInfo)) { process.WaitForExit(); result.ExitCode = process.ExitCode; result.ExitCodeMessage = new Win32Exception(process.ExitCode).Message; switch (result.ExitCode) { case (int)WindowsUninstaller.WindowsExitCode.Restart: case (int)WindowsUninstaller.WindowsExitCode.Reboot: result.Restart = true; result.Success = true; break; case (int)WindowsUninstaller.WindowsExitCode.Sucessful: result.Success = true; break; default: result.Success = false; break; } var output = process.StandardOutput; result.Output = output.ReadToEnd(); } return result; } catch (Exception e) { Logger.Log("Custom App Installer failed to install: {0}.", LogLevel.Error, processInfo.FileName); Logger.LogException(e); result.ExitCode = -1; result.ExitCodeMessage = String.Format("Custom App Installer failed to install {0}.", processInfo.FileName); result.Output = String.Empty; result.Restart = false; result.Success = false; return result; } }