views:

236

answers:

2

I have a bootstrapper application which installs several MSI packages. However, it seems that windows installer does not return any error code if the installation fails. For example, the following command line test does not print "failed" if I hit "cancel":

msiexec /i myinstaller.msi || echo failed

Given the lack of error feedback, what is the best way to detect an installation failure?


As the accepted answer suggests, an error code is actually returned. For some reason my test case only works as expected when executed from a batch file, rather than typed directly at a command line.

+3  A: 

Actually, msiexec does return error codes, the two success codes being 0 (success) and 3010 (success, reboot required). Maybe cmd.exe does some unwanted magic in your example (like returning before msiexec has finished), but I successfully read msiexec error codes when executing it via VBScript's WScript.Shell Run (with bWaitOnReturn = True).

Try throwing the following in a test.vbs file and then executing it with cscript test.vbs:

Set WshShell = WScript.CreateObject("WScript.Shell")
MsgBox(WshShell.Run("msiexec /i myinstaller.msi", , true))

It should pop up with a non-zero value if you hit Cancel.

Heinzi
+1  A: 

msiexec does return an error on installation failure. To catch a user cancel, you might need to use a MIF file.

Jeff Paquette

related questions