Pass setup exit code back to caller

89 views
Skip to first unread message

Ronaldo Souza

unread,
Nov 19, 2021, 1:16:26 PM11/19/21
to innosetup
Hi!
We have a simple app that has a "Check for updates" menu entry.
Basically it does the following:
1) Checks if there's a newer version available for download
2) If so, download and test its updater (File size and SHA1)
3) Call ShellExecute(Updater...,'/SILENT',..)
4) Call Application.Terminate since the EXE itself will be also updated

My problem is that a can only know if the ShellExecute was ok; I can't say anything about the updater itself: if it encounter an error, if the user aborted it, and so on.

Our updaters have the option to run the caller back, so I thought I could pass the exit code as a command line parameter to the main app (who called the updater):

[Run]
;If this updater was called with a "/ReturnToApp" parameter, execute the caller upon termination
Filename: "{app}\{#AppFolder}\{#ThisProgram}.exe"; Description: {cm:LaunchProgram,{cm:RunThisAppOnExit}}; Flags: nowait postinstall; Check: CheckReturnToAppOnExitParm

This has been working, so I thought I could just add a parameter to the [Run] entry above, something like:
     Parameters: "/UpdateRetCode=XXX"

I don't know if it even makes sense to ask for an exit code from within the updater, and I'm chasing my own tail here, but I'd like to know if there's a way to obtain the exit code of the updater in this postinstall run entry, replacing the "XXX" above by the actual exit code of the updater.

Hope this makes sense... :-)

Thanks a bunch in advance!
Best regards,
Ronaldo



Gavin Lambert

unread,
Nov 21, 2021, 5:39:08 PM11/21/21
to inno...@googlegroups.com
On 20/11/2021 07:16, Ronaldo Souza wrote:
> [Run]
> ;If this updater was called with a "/ReturnToApp" parameter, execute the
> caller upon termination
> Filename: "{app}\{#AppFolder}\{#ThisProgram}.exe"; Description:
> {cm:LaunchProgram,{cm:RunThisAppOnExit}}; Flags: nowait postinstall;
> Check: CheckReturnToAppOnExitParm
>
> This has been working, so I thought I could just add a parameter to the
> [Run] entry above, something like:
>      Parameters: "/UpdateRetCode=XXX"
>
> I don't know if it even makes sense to ask for an exit code from within
> the updater, and I'm chasing my own tail here, but I'd like to know if
> there's a way to obtain the exit code of the updater in this postinstall
> run entry, replacing the "XXX" above by the actual exit code of the updater.

Postinstall entries won't be run unless all of the following apply:

1. the installation was successful
2. a reboot is not required
3. the user did not untick the checkbox to run it at the end

So therefore there's no point in asking for an exit code, because it
will always be zero.


For a more robust approach, what you could instead do is to run a third
executable from your app that launches the installer itself and monitors
its exit code and relaunches your app or not as appropriate. Although
then this third exe becomes harder to update from the installer, so
you'd need to take that into account too.
Reply all
Reply to author
Forward
0 new messages