PDA

View Full Version : Return error code from failed msi to vbscript



Christoph
09-19-2014, 08:42 AM
I have a parent msi installer where I call a vbscript that calls a silent install of a child msi. Both msi installers are written by me...

The vbscript looks like:
call objShell.Run(strPath,0,true) where strpath = msiexec.exe /i "child.msi" /qn /norestart /L*v <path to logfile>.

If the child msi fails at some point, it rollbacks and the parent process continues... without informing the user that something went wrong.

Is there a possibility to pass a returncode from the child msi to the calling vbscript (and from the vbscript to the calling parent msi)?
Is some property is setted when during a silent install a rollback has been initiated or something else...?

Thanks!

MichaelU
09-19-2014, 10:52 AM
This is fully up to you, within the constraints of Windows Installer. Msiexec.exe will return a code similar to those returned from MsiInstallProduct (http://msdn.microsoft.com/en-us/library/aa370315.aspx) (e.g. 0 for success, 1603 or similar for various errors), and I assume that vbscript will give you a way to access this. However if you return an error code from a custom action in the outer project, it will immediately fail the outer installation. If you're in an immediate action, you can probably set a property that can be shown on a dialog. Otherwise about all you can do is call Session.Message to inform the user (if the outer installation is being run with UI), and then return either a success or failure code, respectively allowing the outer installation to continue, or causing it to abort and likely roll back.

Windows Installer isn't all that well suited for installing multiple packages this way; it may be worth examining a bootstrap-driven approach (such as using prerequisites in your Basic MSI project or using a Suite project).