Tuesday, January 3, 2012

Legacy Installation Script Wrapper

When an installation is completed it returns an Error Code to Specops Deploy. If it's a 0 we consider the installation successful and 1 is usually Successful but need to reboot and everthing else is an Error. Though, there are installation programs that does not follow this Standard, which makes it possible for you to Specify an alternate Success Exitcode. That's not always enough, since more than 1 Exit Code can be considered a success. Here is a small example of a Install Script you can use to launch your installation and add Error handling.

@Echo off 
Rem This is a example of a wrapper that will translate the exitcode of an installation to something else. 
rem normally it would be something like this. 
rem %specopsdeploymentdir%\install.exe /command /line /switches 
rem just using Ping as example 
ping -n 1
rem ping -n 1

REM If the ping is successfull it will give 0 
REM IF the ping can't ping the host it will give 1

Echo Real ErrorCode from installer: %errorlevel%

if %errorlevel% == 0 goto success 
if %errorlevel% == 1 goto minorproblem
if %errorlevel% == 2 goto minorproblem
if %errorlevel% == 255 goto success
set realerr == %errorlevel%
goto Error 

Echo doing a exit with the real errorcode 
exit /B %realerr% 

Echo Just a MinorProblem, so Setting ErrorLevel to 0 
exit /B 0

Echo Success, so exiting with ErrorCode 0 
exit /B 0

# End of Script 
So it will be something like this. Notice the Real Errorcode after the command and what it will actually exit with and report to Specops Deploy;

No comments:

Post a Comment

Post a Comment