Archive: How to set exit errorlevel code


How to set exit errorlevel code
I am trying to find how to set an exit errorlevel code. I am using NSIS for automation, and would like to know via ye olde %errorlevel% whether the install finished with an eorror, and if possible different errors. For example 0 for no error, 1 for missing prerquisits, 2 for...you get the idea.

thanks in advance


This section of the documentation describes the error levels. You can't change the error level to whatever value you want. You'll have to find another way such as writing to an INI file, creating files or writing to the registry.


Is this still true? Is there no way to return a custom errorlevel exit code from the nsis process? And if not, is this a feature that will ever be implemented? Thanks.

Marianne


NSIS still uses the same error levels.

See the NSIS Website for information about submitting feature requests.


Accessing errorlevel from commandline
I'm trying to view the errorlevel from the cmdline, but the value doesn't seem accurate.

Here is my script for causing a "failure" errorlevel:

#############################
OutFile "c:\temp\testErrorlevel.exe"

Section ""
SetErrors
SectionEnd
#############################

Here's one for "success":

#############################
OutFile "c:\temp\testNoErrors.exe"

Section ""
ClearErrors
SectionEnd
#############################

And here are my test results:
#############################
C:\temp>testErrorlevel

C:\temp>echo %errorlevel%
9009

C:\temp>testNoErrors

C:\temp>echo %errorlevel%
9009
#############################


Try to get the error level from another NSIS script using Exec.


I need to communicate my error status to a non-NSIS executable that invokes my module, so using Exec and IfError don't really help.


ExecWait can get the error level. ExecWait waits for the NSIS installer to finish, a DOS box doesn't. 9009 is probably the error level of the application you ran just before the installer.

SetErrors and ClearErrors is for the script. The error level is not set by them. It is set to a value different than zero if the installation was aborted. As the documentation states:

* 0 - Normal execution (no error)
* 1 - Installation aborted by user
* 2 - Installation aborted by script

If 'SetErrors' is replaced by 'Abort' in the script above, and 'ClearErrors' by 'Quit', the test results are still the same.


The first paragraph addresses that.


Sorry, that's a bit too cryptic for me.

How is ExecWait relevant if I'm checking the errorlevel from the commandline? If you would modify my samples so the tests work correctly, that would help tremendously.


The command line doesn't wait for the installer and therefore can't get its error level.


see this thread.