How to trap an error in a package which is caused by a non-zero return value from an installer
|Article:TECH109927|||||Created: 2007-01-09|||||Updated: 2007-01-17|||||Article URL http://www.symantec.com/docs/TECH109927|
A software installer file, such as an MSI file, ran a successful install or uninstall but the computer and package showed an Error status.
After the deployment of a package which runs an MSI install or uninstall, Command Center shows an Error status for both the package and computer. However, upon examination of the client computer, it appears that the MSI action completed successfully.
iCommand or LiveState Delivery package runs an MSI file or other type of installer which returns a non-zero value for success.
Some installers, such as MSI files, return a non-zero value for success. The LiveState Windows Agent sets an Error status when it detects a non-zero return value.
This example will demonstrate the solution using an MSI installer. This same solution may apply to other installer types as well, such as executable files, by running the executable (instead of msiexec.exe as shown below) from a BAT file.
From the package, call a BAT file, let's call it runmsi.bat, like this:
The runmsi.bat file should be included with the Script fileset. Its contents may be something like this:
- @echo on
cmd.exe /c msiexec.exe /i "\\%DEPOT_SERV%\%DEPOT_SERV_SHARE%\%DEPOTDIR%\whatever.msi" /qb
echo "errorlevel = %errorlevel%"
if "%errorlevel%" == "3010" goto needreboot
if "%errorlevel%" == "1638" goto alreadyinst
if not "%errorlevel%" == "0" goto err
if "%errorlevel%" == "0" goto end
rem print message and return success
echo "Msiexec installation was successful, but it requires a reboot."
rem print message and return zero (so the package doesn¿t error)
echo "Msiexec returned 1638, product already installed"
exit /b 0
rem print message and return errorlevel so package errors
echo "Error: Msiexec failed with errorlevel = %errorlevel%"
exit /b %errorlevel%
The MSI file in this example would be part of the Vendor fileset. Call the msiexec command from within a bat file to prevent the Windows Agent from detecting a non-zero return value, which puts it into an Error status. Trap the non-zero return value by checking for all possible successful return values (3010 and 0 in this example). Contact the original author of the installer for a list of possible successful return values.
Also in this example, note the check for errorlevel 1638, which means that the msiexec installer found an existing version of the software that it is trying to install.
When the return value from the msiexec call is an actual error, return a non-zero value back to the package using the "exit /b value" command. This sets the package to an Error status.
Article URL http://www.symantec.com/docs/TECH109927