check_innosetup-exitcode

Script by Der-Matze
Comments and improvements welcome

Tested with opsi 4.0.1
Tested with opsi-winst 4.10.x - 4.11.1.6
Tested with Windows XP Professional and Windows 7 Enterprise x64

Subscript that checks all available innosetup exitcodes, writes the definition of the encountered exitcode to the logfile and determines if the installation was successful or not.
Makes debugging installations easier and assures that failed installations show up as failed in configed.

Usage:

Winbatch_Install
 
	sub "%ScriptDrive%\install\check_exitcode\check_innosetup-exitcode.ins"

References: http://unattended.sourceforge.net/InnoSetup_Switches_ExitCodes.html

check_innosetup-exitcode.ins

;Den ExitCode des Installers abfragen
	set $ExitCode$ = getLastExitCode
 
 
 
;Loglevel anpassen
	setLogLevel = 4
 
 
 
;Den ExitCode auswerten
 
if ($ExitCode$ = "0")
	setLogLevel = 5
		comment "ExitCode = "+$ExitCode$+" Setup was successfully run to completion."
			setLogLevel = 4
 
endif
 
 
 
if ($ExitCode$ = "1")
 
	setLogLevel = 5
		logError "ExitCode = "+$ExitCode$+" Setup failed to initialize."
			isFatalError
 
endif
 
 
 
if ($ExitCode$ = "2")
 
	setLogLevel = 5
		logError "ExitCode = "+$ExitCode$+" The user clicked Cancel in the wizard before the actual installation started, or chose "No" on the opening "This will install..." message box."
			isFatalError
 
endif
 
 
 
if ($ExitCode$ = "3")
 
	setLogLevel = 5
		logError "ExitCode = "+$ExitCode$+" A fatal error occurred while preparing to move to the next installation phase (for example, from displaying the pre-installation wizard pages to the actual installation process). This should never happen except under the most unusual of circumstances, such as running out of memory or Windows resources."
			isFatalError
 
endif
 
 
 
if ($ExitCode$ = "4")
 
	setLogLevel = 5
		logError "ExitCode = "+$ExitCode$+" A fatal error occurred during the actual installation process."
			isFatalError
 
endif
 
 
 
if ($ExitCode$ = "5")
 
	setLogLevel = 5
		logError "ExitCode = "+$ExitCode$+" The user clicked Cancel during the actual installation process, or chose Abort at an Abort-Retry-Ignore box."
			isFatalError
 
endif
 
 
 
if ($ExitCode$ = "6")
 
	setLogLevel = 5
		logError "ExitCode = "+$ExitCode$+" The Setup process was forcefully terminated by the debugger (Run | Terminate was used in the IDE)."
			isFatalError
 
endif
 
 
 
;Loglevel anpassen
	setLogLevel = 6