I knew I would find the answer after bugging you folks. See http://stackoverflow.com/questions/4632891/exiting-batch-with-exit-b-x-where-x-1-acts-as-if-command-completed-successfu.

The script has to look like this:

cd $USER_INSTALL_DIR$

:: Get the list of files with the read-only attribute set.
:: This post-install script restores the read-only attribute
:: to the files in the list.
::
:: If the system encounters a system where there is not
:: read-only attribute set, bail out with an error.
dir /a:r-h /s /b>%AttrFile%
if %errorlevel% neq 0 (
call :complain "ERROR: %errorlevel% : read-only attribute not set for any file"
goto :end
)

....
:: Name : complain
::
:: Purpose : Issues error message to logfile.
::
:: Parameters :
:: msg - Error message handling
:: %1 - Error Message
::
:: Increments wmerrors
::
:complain
setlocal
(set msg=%~1)
set emsg="[%date% %time% %wmhost%] %msg%"
echo %emsg:~1,-1% >> %LogFile%
endlocal
goto :eof
...

:end
%comspec% /c exit %errorlevel%

That works. The entry I saw at the link is:


I was confused for a bit, so this is just a note for others that you literally need that to be the last line of the file. It won't actually exit the batch, just set the error code. Calling EXIT /B %ERRORLEVEL% directly after it doesn't always seem to work either. The only reliable method I found was to use IF ERRORLEVEL 1 goto :end and have a label :end just before the last line with %COMSPEC% /C EXIT %ERRORLEVEL%>NUL – Jordan Evens Jan 10 '11 at 14:34