Home > Back-end >  Catch msiexec command failure inside Process.Start
Catch msiexec command failure inside Process.Start

Time:12-29

I want to install an MSI using process.start and below is the code I added.

try {
  Process p = Process.Start("msiexec.exe", "/a D:\test.msi");
  //msiexec.exe /a "D:\test.msi"
} catch(Exception Ex) {
  //handle exception
}

I expected it to go to catch block if the msiexec command inside fails.

But looks like command execution status doesn't matter for Process.start.

How can I know if the command inside is successful or not?

CodePudding user response:

(In Windows) it is customs a successful exe return 0. Any other value signals an error.
You find the valiue in ExitProperty
If you want to find out what failed you might have to send the output to a console.

  • Related