Frank
Frank

Reputation: 165

How can I get an install4j installer to fail based on a Windows batch command error level

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:

  1. I tried simply setting the failure strategy in the Run batch file action to Quit on Failures, this didn't work.
  2. 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?

Upvotes: 0

Views: 1435

Answers (1)

Frank
Frank

Reputation: 165

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.

Upvotes: 1

Related Questions