Error Levels

NSIS

Previous | Contents | Next

D.1 Error Levels

Like other applications, installers made by NSIS return error levels as a result of their execution. Checking the error level can be useful if you call an NSIS installer from another application or installer.

  • 0 - Normal execution (no error)
  • 1 - Installation aborted by user (cancel button)
  • 2 - Installation aborted by script

As of NSIS 2.01, you can set the error level to other values using SetErrorLevel.

Note that uninstallers copy themselves to the temporary directory and execute from there so the original uninstaller can be deleted. This means the error level the uninstaller sets is not available to the executing process, unless it simulates this copy process and executes the copied uninstaller. To simulate this process, use:

InitPluginsDir
CopyFiles $INSTDIR\uninstaller.exe $PLUGINSDIR
ExecWait '"$PLUGINSDIR\uninstaller.exe" _?=$INSTDIR' $0
DetailPrint "uninstaller set error level $0"

If you don't do this, you'll only be able to know if the uninstaller failed copying itself to the temporary directory.

Previous | Contents | Next