Well
9th August 2005 09:51 UTC
makensis: Stop on error
Hi everyone,
Have a simple request and will be very happy if it can be done. I'm batch-building a lot of installs, the result files are compilled with another ones, then all this stuff gets archived, time-stamped and uploaded - a completely automated double-click solution. The nasty part comes when I miss some file in some of the installs - the install surely gives some error but it gets lost in the tons of messages, then the archive gets compilled with some install missing, then uploaded and I got a problem later.
The obvious answer is: "Do it more carefully", but I'm just a human and making mistakes.
Can there be an option added in makensis to just hang there upon error so it can attract my attention?
Thanks
stb
9th August 2005 09:54 UTC
AFAIK: NSIS sets errorlevel on exit.
makensis.exe my.nsi
@IF ERRORLEVEL==1 GOTO error
goto finish
:error
pause
:finish
Well
9th August 2005 09:58 UTC
OMG completely forgot about the errorlevel... will try that now... thanks
Well
9th August 2005 16:39 UTC
Nope, it don't work :(
stb
9th August 2005 17:11 UTC
It DOES work, here's a full example.
c:\test.bat
@echo off
c:\programme\nsis\makensis.exe c:\test.nsi
@IF ERRORLEVEL ==1 GOTO error
echo "Ready"
goto end
:error
echo "ERROR!"
pause
:end
c:\test.nsi
OutFile "c:\test.exe"
Section Test
File "c:\test2.bat"
SectionEnd
Run "test.bat" and see an error. If you change the File command int c:\test.nsi to the correct path "c:\test.bat" all runs fine (and the batch script skips "pause").
Well
10th August 2005 12:18 UTC
Uh... thanks... I have changed the code to your way and it worked indeed... however reverted back to mine and it does not work agai... just curious why:
"C:\Program Files\NSIS\makensis.exe" /V2 tmpinst.nsi
@IF ERRORLEVEL==0 GOTO END
echo FAILURE BUIDLDING INSTALLATION FOR: %shortname% - %which%
pause
:END
however that way works:
"C:\Program Files\NSIS\makensis.exe" /V2 tmpinst.nsi
@IF ERRORLEVEL==1 GOTO ERROR
goto END
:ERROR
echo FAILURE BUIDLDING INSTALLATION FOR: %shortname% - %which%
pause
:END
Strange...
pengyou
10th August 2005 13:47 UTC
however reverted back to mine and it does not work agai... just curious why
The answer is quite simple. Although the ERRORLEVEL tests appear to test for equality, they actually test for "greater than or equal to".
So if you want to test for several ERRORLEVEL values you need to do so in descending order, like this:
IF ERRORLEVEL 3 GOTO ERROR_3
IF ERRORLEVEL 2 GOTO ERROR_2
IF ERRORLEVEL 1 GOTO ERROR_1
(note that label ERROR_3 will be jumped to if the ERRORLEVEL is 3 or higher)
If you used this order,
IF ERRORLEVEL 1 GOTO ERROR_1
IF ERRORLEVEL 2 GOTO ERROR_2
IF ERRORLEVEL 3 GOTO ERROR_3
then the batch file would always jump to label ERROR_1 when ERRORLEVEL was 1, 2, 3, or any higher value.
So when you used "IF ERRORLEVEL==0 GOTO END" your batch file would also jump to END when the ERRORLEVEL was 1
Well
10th August 2005 16:38 UTC
lol
Okay I got it... the mistery is solved, thanks guys :)
l_d_allan
16th May 2006 21:13 UTC
I'm doing something similar to the original post, and was wondering if makensisw.exe has a return-code that
IF ERRORLEVEL
can handle.
It seems to invariably return 0.
rem RebuildInstallers.bat 2006-May-16 LDA
X:\DevTools\nsis\makensisw HasError.nsi
IF ERRORLEVEL 3 goto ReportLevel3Error
IF ERRORLEVEL 2 goto ReportLevel2Error
IF ERRORLEVEL 1 goto ReportLevel1Error
IF ERRORLEVEL 0 goto ReportLevel0Error
:ReportLevel0Error
echo Reached ERRORLEVEL 0
goto Finished
:ReportLevel1Error
echo Reached ERRORLEVEL 1
goto Finished
:ReportLevel2Error
echo Reached ERRORLEVEL 2
goto Finished
:ReportLevel3Error
echo Reached ERRORLEVEL 3
goto Finished
:Finished
pause
kichik
19th May 2006 11:38 UTC
makensisw has no return code, only makensis.