I have a windows batch cmd *.cmd file that runs sql, as part of my installer. This script returns a proper non-zero return code when the sql fails. I can’t get my install4j installer to recognize the return code.
I tried two things:
- I tried simply setting the failure strategy in the Run batch file action to Quit on Failures, this didn’t work.
- I tried setting the value of the return code in a variable (sqlReturnCode) and checking that variable in a subsequent action, that didn’t work.
When I checked the installation log I’m seeing the SQL errors from stderr redirected to the log, but no matter if it succeeds or fails I see this:
[INFO] com.install4j.runtime.beans.actions.misc.RunExecutableAction [ID 72]: Variable changed: sqlReturnCode=0[class java.lang.Integer]
It’s always setting that variable to zero. I DO NOT have the “Show Console Window” option checked. Is this a known bug? How can I fix/work around it?
This ended up being a problem with the cmd script being executed. The ERRORLEVEL enivonrmental variable was being set but “exit /b %ERRORLEVEL%” was not being called.
Install4j relies on the proper error level being set with the exit command.