TomGarrett
Posts: 25
Joined: Fri Nov 16, 2007 12:44 pm

Using custom action (batch file) return codes

Hello,

I'm attempting to add some validation into the install process so that if batch files fail due to missing files or Database servers failure etc the Installer will abort and rollback.

I assumed that by checking the return code, an invalid code would cause an error to be raised - however I think I may be confused as to whether it is viewer.exe returning the code or if it is the batch file.

The result of the actions specified below result in the pause of the batch file being hit, but after a key is pressed the installer carrys on regardless.

So, in the Commit section of the install sequence I have a "file attached to installation" action (source path: viewer.exe, source type: exe).
Command line: "[#install_lis.bat]" [APPDIR] [J2SDK_DIRECTORY]
And I've tried to add some protection in the batch file as follows:

@echo off
set APP_DIR=%1
set J2SDK_DIR=%2
set jintegra_jar=%APP_DIR%Sapphire\JIntegra\lib\jintegra.jar

cd %APP_DIR%Sapphire\JIntegra\lib
set classpath=%jintegra_jar%
set JAVA_HOME=%J2SDK_DIR%\bin
set path=%JAVA_HOME%

IF NOT EXIST jintegra.xml GOTO ERROR

echo Installing JIntegra License
java -cp jintegra.jar com.intrinsyc.license.JintegraLicenseTool clean
java -cp jintegra.jar com.intrinsyc.license.JintegraLicenseTool install
java -cp jintegra.jar com.intrinsyc.license.JintegraLicenseTool view

:END
REM No problem
exit 0

:ERROR
echo Problem found Installing JIntegra License
pause
exit 1


Thanks! And apologies for the long post. :twisted:
Cosmin
Posts: 5797
Joined: Tue Jul 10, 2007 6:39 pm
Contact: Website

Hi,

Please note that batch files are not custom actions supported by Windows Installer (they can be launched by "viewer.exe"). Since "viewer.exe" doesn't parse the batch file to check for errors or outputs, you cannot do what you need with a batch file.

However, you can do this by using a DLL, script or EXE custom action.

Regards,
Cosmin
Cosmin Pirvu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
TomGarrett
Posts: 25
Joined: Fri Nov 16, 2007 12:44 pm

Ok, I'll come up with something!

Thanks.

Return to “Common Problems”