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 |
Problem
A software installer file, such as an MSI file, ran a successful install or uninstall but the computer and package showed an Error status.
Symptoms
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.
Conditions
iCommand or LiveState Delivery package runs an MSI file or other type of installer which returns a non-zero value for success.
Cause
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.
Solution
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:
call runmsi.bat
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 off
echo "errorlevel = %errorlevel%"
if "%errorlevel%" == "3010" goto needreboot
if "%errorlevel%" == "1638" goto alreadyinst
if not "%errorlevel%" == "0" goto err
if "%errorlevel%" == "0" goto end
:needreboot
rem print message and return success
echo "Msiexec installation was successful, but it requires a reboot."
goto end
:alreadyinst
rem print message and return zero (so the package doesn¿t error)
echo "Msiexec returned 1638, product already installed"
exit /b 0
:err
rem print message and return errorlevel so package errors
echo "Error: Msiexec failed with errorlevel = %errorlevel%"
exit /b %errorlevel%
:end
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.
References
Error Codes
|
|
Legacy ID
2007820387423098
Article URL http://www.symantec.com/docs/TECH109927
Terms of use for this information are found in Legal Notices









Thank you.