1

I'm using Inno Setup to deploy an application.

For most cases, a per-user installation that doesn't require admin privileges is fine. However, there are scenarios where I need to install the app for all users, e.g. for Citrix or TSE.

Unfortunately it doesn't seem possible to choose dynamically between per-user and per-machine install. It depends on the PrivilegesRequired setting, which is set at compile time.

My latest workaround attempt almost got me there. Basically I have a setup with PrivilegesRequired set to lowest, and if I need to install for all users, I restart the setup with admin privileges. This works, BUT the uninstall information is still written to HKEY_CURRENT_USER rather than HKEY_LOCAL_MACHINE.

My questions: - is there a way to achieve dual per-user/per-machine install with Inno Setup? (without generating two different installers) - if not, is there a way to write uninstall info to HKEY_LOCAL_MACHINE when PrivilegesRequired is set to lowest?

EDIT: the accepted answer to this question doesn't apply in my case. I want to request UAC elevation only when a specific argument (/AllUsers) is passed on the command line. Without this argument, the UAC prompt shouldn't appear even if the user is an admin. And TLama's answer has the same problem as my current approach.

Community
  • 1
  • 1
Thomas Levesque
  • 286,951
  • 70
  • 623
  • 758
  • Use `PrivilegesRequired=none` instead of the `lowest`. – Martin Prikryl Mar 07 '17 at 21:59
  • @MartinPrikryl I'll give it a try, but does it write to `HKEY_LOCAL_MACHINE` when running as admin and `HKEY_CURRENT_USER` when running as non-admin? – Thomas Levesque Mar 07 '17 at 22:17
  • @MartinPrikryl ok, that won't help. I want to run elevated only when a specific argument is passed on the command line. I don't want the UAC prompt to pop up, even for an admin user, unless they passed this argument. Thanks anyway! – Thomas Levesque Mar 07 '17 at 22:31
  • Than, see this: [Specify the registry uninstall key location/hive via \[Code\]](http://stackoverflow.com/q/37221915/850848) (particularly the second part of [my answer](http://stackoverflow.com/a/37224058/850848)). – Martin Prikryl Mar 08 '17 at 06:59
  • @MartinPrikryl thanks. I thought of doing this, but it seemed unelegant. Also, InnoSetup won't know look at the key in HKLM when I run the setup again, which is annoying... – Thomas Levesque Mar 08 '17 at 09:35
  • There's no elegant solution to this problem + Why would not the setup look to HKLM? It always looks both to the HKCU and HKLM (in this order), no matter what. – Martin Prikryl Mar 08 '17 at 10:18
  • @MartinPrikryl, ah, good to know. I thought it looked only in HKCU when PrivilegesRequired was set to lowest. – Thomas Levesque Mar 08 '17 at 11:28
  • You are welcome. – Martin Prikryl Mar 08 '17 at 12:26

0 Answers0