Is it possible to determine PrivilegesRequired programmatically

100 views
Skip to first unread message

Paul Gardiner

unread,
Aug 20, 2023, 11:40:41 AM8/20/23
to innosetup
I have an installer for an app that can install either for the current user or for all users. I wish to make an installer for an add on to the app. The add on installer needs raised privileges only if the main app was installed for all users. I can't see how to automate that choice in the add on installer. I can set PrivilegesRequiredOverridesAllowed to dialog so that the end user can decide, but that's expecting knowledge they may not have. Is there a nice way to do this?

I've seen some posts about killing the process and restarting it. I'm hoping that isn't the only way.

Jernej Simončič

unread,
Aug 21, 2023, 2:39:50 AM8/21/23
to 'Paul Gardiner' via innosetup on [innosetup]

On Sunday, August 20, 2023, 17:40:40, 'Paul Gardiner' via innosetup wrote:


I have an installer for an app that can install either for the current user or for all users. I wish to make an installer for an add on to the app. The add on installer needs raised privileges only if the main app was installed for all users. I can't see how to automate that choice in the add on installer. I can set PrivilegesRequiredOverridesAllowed to dialog so that the end user can decide, but that's expecting knowledge they may not have. Is there a nice way to do this?

Have a look at what I did with the GIMP Help installer: https://gitlab.gnome.org/GNOME/gimp-help/-/blob/master/build/windows/installer/gimp-help.iss

 

What I did is to have the installer run in multiple phases – when run without parameters, it looks in Registry for per-user and all users GIMP installs, and shows a page where you can select where to install the Help add-on to, then depending on your choice it restarts the installer with /SILENT and /CURRENTUSER or /ALLUSERS parameters.


-- 
< Jernej Simončič ><><><><>< https://eternallybored.org/ >


It's always the wrong time of the month.
       -- Astrology Law

Paul Gardiner

unread,
Aug 22, 2023, 6:51:52 AM8/22/23
to innosetup
Thanks Jernej. More effort than I was hoping to go to, but does look to be the best approach.

Paul Gardiner

unread,
Aug 23, 2023, 8:48:59 AM8/23/23
to innosetup
Jernej, for the phased method to work, the actuall install part of Phase 1 has to be aborted. I see your script sometime returns 'Abort' from PrepareToInstall and sometimes calls Abort() in CurStepChanged. When I do either of those an error message is shown. What am I missing?

Jernej Simončič

unread,
Aug 23, 2023, 2:31:55 PM8/23/23
to 'Paul Gardiner' via innosetup on [innosetup]

On Wednesday, August 23, 2023, 14:48:59, 'Paul Gardiner' via innosetup wrote:


Jernej, for the phased method to work, the actuall install part of Phase 1 has to be aborted. I see your script sometime returns 'Abort' from PrepareToInstall and sometimes calls Abort() in CurStepChanged. When I do either of those an error message is shown. What am I missing?

IIRC, PrepareToInstall returns 'Abort' when running in interactive mode, then CurPageChanged modifies the wpPreparing page to replace the error message with a pseudo-finished page; in silent mode, Abort is called from CurStepChanged(ssInstall), where it should silently exit the setup.

 

-- 
< Jernej Simončič ><><><><>< https://eternallybored.org/ >


A proliferation of new laws creates a proliferation of new loopholes.
       -- Cooper's Metalaw

Paul Gardiner

unread,
Aug 24, 2023, 7:59:12 AM8/24/23
to innosetup
It was just me getting confused when running it from the debugger. All fine now. Thanks for the help.
Reply all
Reply to author
Forward
0 new messages