Bypass the Finished page without automatically restarting

516 views
Skip to first unread message

Christian Blackburn

unread,
May 25, 2022, 8:17:20 PM5/25/22
to innosetup
Hi Guys,

I'm using ShouldSkipPage() to optionally bypass the Finished page.  There are some choices on the Tasks page as to what my installer will do once it finishes (Prompt, Restart, Shutdown, etc.).  I also have some settings marked with "Flags: Restart".  In addition I have
[Setup]
AlwaysRestart=No

So yeah there are times it "should" restart, but if I'm bypassing the wpFinished page, how can I keep Inno Setup from always restarting?  I "solved" this by spawning a second program that just terminates the installer (which loops until it's killed) before it could restart, but that seems like a hack at best.  

Thanks,
Christian Blackburn

Wilenty

unread,
May 26, 2022, 3:02:38 PM5/26/22
to innosetup
Hello,
did you checked the "Pascal Scripting: Event Functions" from there: https://jrsoftware.org/ishelp/index.php?topic=scriptevents ?

There are a function to: "Return True to instruct Setup to prompt the user to restart the system at the end of a successful installation, False otherwise."

If it won't helps, please share example script.

Christian Blackburn

unread,
May 26, 2022, 7:18:45 PM5/26/22
to innosetup
Hi Wilenty,

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


Thanks,
Christian Blackburn

Gavin Lambert

unread,
May 26, 2022, 7:36:01 PM5/26/22
to inno...@googlegroups.com
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.)

Christian Blackburn

unread,
May 27, 2022, 11:24:21 PM5/27/22
to innosetup
Hi Gavin,

Thanks for your helpful suggestions.  #3 /NORESTART will come in handy in some situations.  The reason I'm wanting to bypass the final page is my installer gives the option to exit, restart, or shutdown at the end of an installation.  I'm in a hardware test environment where these options make sense.    

Thanks,
Christian Blackburn
Reply all
Reply to author
Forward
0 new messages