On 27/05/2022 11:18, Christian Blackburn wrote:
> Thank you very much for your reply. I'd forgotten about this
> NeedRestart() function. I didn't realize there was a separate one for
> the Uninstaller too:
> function UninstallNeedRestart(): Boolean;
>
> However, I now see why I tried it in the past and elected not to use
> it. It needs to have a boolean argument that lets you know whether or
> not Inno Setup itself thinks a restart is necessary. I guess I have to
> do my best to track it with a boolean variable.
>
> It should pay attention to the following:**
> *Flags:* *restartreplace restart uninsrestartdelete *
> and
> *[Setup]:
> RestartIfNeededByRun=Yes*
That's not really needed. The purpose of both event functions is to
tell Inno that you have done something in code that will require a
restart. It cannot clear the internal "needs restart" flag, it can only
set it.
Don't try to skip the finished page in the first place; it exists for a
good reason. Why are you trying to do so?
If you want to avoid Inno triggering a restart, then you have only three
alternative options:
1. Don't do anything that would require a restart in the first place.
2. Get the user to choose to not restart at the end.
3. Launch the installer in the first place with the /NORESTART parameter.
#3 is typically preferred when the installer is launched from another
parent installer. Ideally you should inspect the exit code and have the
parent installer request a restart in its place at that point, although
it's sufficient to use [Run] and RestartIfNeededByRun if the parent is
an Inno installer. (Although note that using [Run] will not allow you
to react to other errors the installer might report, so it's often
better to run it from [Code], which is where the parent installer might
need to implement NeedRestart to report the status of the child.)