Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Catch msiexec command failure inside Process.Start

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.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

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

>Solution :

(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.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading