How can I access the return code of Inno Setup based installer?
For example, this documentation says that exit code will be 1 if "Setup failed to initialize". In my installer, in some cases, code returns False from InitializeSetup(). I am running the installer with /silent flag on command prompt. If I echo %errorlevel%, I get 0.
Relevant portion of code from the InitializeSetup() function:
function InitializeSetup(): Boolean;
var
ResultCode: Integer;
begin
{ In silent mode, set Result to false so as to exit before wizard is }
{ launched in case setup cannot continue. }
if WizardSilent() then
begin
{ CompareVersion() logically returns the -1, 0 or 1 based on }
{ whether the version being installed is less than, equal to or greater }
{ than version already installed. Returns 0 is there is no existing }
{ installation. }
ResultCode := CompareVersion();
if ResultCode < 0 then
begin
Result := False;
Exit;
end;
end;
Result := True;
end;
From command line, here is how I am running and capturing return value:
C:\VersionCheck>myinstaller.exe /Silent
C:\VersionCheck>echo %errorlevel%
0
C:\VersionCheck>
The log file shows :
2016-09-29 08:05:11.259 Log opened. (Time zone: UTC-07:00)
2016-09-29 08:05:11.259 Setup version: Inno Setup version 5.5.9 (u)
2016-09-29 08:05:11.259 Original Setup EXE: C:\VersionCheck\myinstaller.exe
2016-09-29 08:05:11.259 Setup command line: /SL5="$9051C,3445541,131584,C:\VersionCheck\myinstaller.exe" /Silent
2016-09-29 08:05:11.259 Windows version: 6.3.9600 (NT platform: Yes)
2016-09-29 08:05:11.259 64-bit Windows: Yes
2016-09-29 08:05:11.259 Processor architecture: x64
2016-09-29 08:05:11.259 User privileges: Administrative
2016-09-29 08:05:11.259 64-bit install mode: Yes
2016-09-29 08:05:11.259 Created temporary directory: C:\Users\ADMINI~1\AppData\Local\Temp\2\is-TQB2V.tmp
2016-09-29 08:05:11.275 Installed version component : 3
2016-09-29 08:05:11.275 Updating to version component : 0
2016-09-29 08:05:11.275 This computer already has a more recent version (3.5.0.0) of XYZ. If you wantto downgrade to version 0.0.0.0 then uninstall and try again. Setup will exit.
2016-09-29 08:05:11.275 InitializeSetup returned False; aborting.
2016-09-29 08:05:11.275 Got EAbort exception.
2016-09-29 08:05:11.275 Deinitializing Setup.
2016-09-29 08:05:11.275 Log closed.
Is there something I am missing?
FalsefromInitializeSetup. If you do not, show us an exact command sequence you use to run the installer and check the exit code, including a complete output. - Martin Prikryl