2

I'm currently using the Qt-Installer-Framework to create a setup for my application. Everything works fine for now except one thing:

If I install it to any location but C:\Program Files\MyApp, the installer won't create the registry entry for Programs and Features!

Is there a way to tell the installer to always do this?

Edit:
After trying out vairous different combinations, I do know now where the problem comes from:

If I try to install as current user only (set the AllUsers variable to false), it will always work and create an entry in HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{GUID}.

If I install for all users, however, it will try to create a key in HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{GUID}. This will only work, if the installer has to elevate it's operations during installation (because I chose a directory I need admin rights for).

So, the error is: The installer won't elevate itself to create the "global" registry entry and thus fails to create it. Any ideas on how to fix it?

Felix
  • 6,885
  • 1
  • 29
  • 54
  • It's a Windows 10 machine – Felix Jan 19 '16 at 16:05
  • How do you switch between `AllUsers` `true` and`false`? I can't find anything regarding this option in the docs. https://stackoverflow.com/questions/59510656/how-to-distinguish-per-user-vs-system-wide-installation-in-qt-installer-framewo – Thorsten Schöning Jan 05 '20 at 19:05
  • 1
    @ThorstenSchöning I just checked and it is an extension, used by an advanced controller script. See https://github.com/Skycoder42/QtIFW-Advanced-Setup/blob/master/installer/config/controller.js – Felix Jan 05 '20 at 19:45
  • Thanks, the important thing is to set the value earlier than I did using `installer.setValue`. Besides that, one can provide that on the shell as well: `installer.exe AllUsers=true` https://bugreports.qt.io/browse/QTIFW-124 – Thorsten Schöning Jan 05 '20 at 20:04

2 Answers2

2

Here the link which has answer to this question.

Add the following line to your component's package xml file:

@<RequiresAdminRights>true</RequiresAdminRights>@

And use this line in your script file:

@component.addElevatedOperation("Execute", "someCommand");@

instead of

@component.addOperation("Execute", "someCommand");@

Community
  • 1
  • 1
Evgeny
  • 3,910
  • 2
  • 20
  • 37
  • I know this one. However, I don't want to always run as admin, only elevate if the setup is being installed for all users (decided at runtime with a custom page). Furthermore, I did not create any operation to add the registry entry. This is done automatically by the installer. – Felix Jan 19 '16 at 16:38
0

There is boolean installer.gainAdminRights() to gain elevated privileges during runtime but you will have to add it to an installer script (in packages meta directory) something alike

function Component()
{
    if (!installer.isInstaller())
    {
        if (allUsers && installer.gainAdminRights())
        {
            //Set registry global
        } else {
            //Set registry local
        }
    }
}
Sebastian Lange
  • 3,879
  • 1
  • 19
  • 38