In my CurStepChanged
procedure I have some code that installs the Visual Studio Redistributable (if required). Code snippet:
if (bVcRedist64BitNeeded) then
begin
if Exec(ExpandConstant(vcRedist64BitPath), '/install /passive /norestart', '',
SW_SHOW, ewWaitUntilTerminated, ResultCode) then begin
{ handle success if necessary; ResultCode contains the exit code }
Log('VS Redist (64 bit) installer exit code = ' + IntToStr(ResultCode));
if not (ResultCode = 0) then begin
MsgBox(ExpandConstant('{cm:InstallFailed,Visual Studio x64 Redistributable}'), mbInformation, MB_OK);
Abort();
end;
end
else begin
{ The execution failed for some reason }
Log('VS Redist (64 bit) installer exit code = ' + IntToStr(ResultCode));
MsgBox(SysErrorMessage(ResultCode), mbInformation, MB_OK);
Abort();
end;
end;
I had a user saying that the installer for my software was failing so I asked them to send me their logs. At the end of all the logs it had similar to this:
2020-09-05 14:37:48.034 VS Redist (64 bit) installer exit code = 3010
2020-09-05 14:37:48.035 Message box (OK):
The installation of Visual Studio x64 Redistributable failed. The Meeting Schedule Assistant installation will be aborted.
2020-09-05 14:38:38.352 User chose OK.
2020-09-05 14:38:38.352 CurStepChanged raised an exception.
2020-09-05 14:38:38.353 Need to restart Windows? No
2020-09-05 14:38:38.373 Exception message:
2020-09-05 14:38:38.374 Message box (OK):
Internal error: Expression error 'Runtime error (at 191:1960):
Exception: Operation aborted.'
2020-09-05 14:38:40.747 User chose OK.
2020-09-05 14:38:40.747 Exception message:
2020-09-05 14:38:40.747 Message box (OK):
Internal error: Expression error 'Runtime error (at 191:1960):
Exception: Operation aborted.'
2020-09-05 14:38:42.082 User chose OK.
2020-09-05 14:38:42.103 Exception message:
2020-09-05 14:38:42.104 Message box (OK):
Out Of Range.
2020-09-05 14:38:44.052 User chose OK.
2020-09-05 14:38:51.259 -- Run entry --
2020-09-05 14:38:51.259 Run as: Original user
2020-09-05 14:38:51.259 Type: Exec
2020-09-05 14:38:51.260 Filename: C:\Program Files (x86)\Meeting Schedule Assistant\MeetSchedAssist.exe
I noticed that the redist setup was exiting with a result of 3010
. I can't find any official documentation about the redist exit codes but it seems to be a soft reboot. Anyway, today they then tried my installer and it worked (since they had switched their PC of last night):
2020-09-06 13:08:38.707 VS Redist (64 bit) installer exit code = 0
2020-09-06 13:09:33.070 VS Redist (32 bit) installer exit code = 0
2020-09-06 13:09:33.071 Need to restart Windows? No
2020-09-06 13:10:07.741 -- Run entry --
2020-09-06 13:10:07.741 Run as: Original user
2020-09-06 13:10:07.741 Type: Exec
2020-09-06 13:10:07.741 Filename: C:\Program Files (x86)\Meeting Schedule Assistant\MeetSchedAssist.exe
So I am assuming that 3010 does mean soft reboot? And if so, is there a better way we can handle this situation in our Inno Setup installation?
If I understand correctly, the exit code means that the installer needs to restart the machine.
In that case, you can implement NeedRestart
event function to request restart, when the exit code was 3010.
Add NeedRestart
event function and NeedsRestart
global variable:
var
NeedsRestart: Boolean;
function NeedRestart(): Boolean;
begin
Result := NeedsRestart;
end;
And modify your exit code testing logic to:
if ResultCode = 3010 then
begin
Log('Need restart');
NeedsRestart := True;
end
else
if ResultCode <> 0 then
begin
MsgBox(
ExpandConstant('{cm:InstallFailed,Visual Studio x64 Redistributable}'),
mbInformation, MB_OK);
Abort();
end;
Similar question: How to restart Inno Setup installer based on result of procedure that executes a program/subinstaller