How to distinguish per-user vs. system-wide instal

2020-05-06 17:04发布

I'm using some app called pgModeler and it's current version provides an installer based on QT installer framework. The problem with that installer on Windows is that it installs start menu entries per-user only and registers the app itself per-user only as well. That's a problem for people like me using an explicit admin-user for system maintenance vs. a non-admin user for daily work. The important thing is that really two different user names are used (Administrator vs. tschoening) instead of Windows' default behaviour to restrict one user using UAC only.

Before switching to QT installer framework, Inno Setup has been used and that has some concept of distinguishing between administrative and system-wide vs. per-user installation. The switch simply was to execute the installer as admin or not, everything else worked automatically and is not the case anymore with QT.

What I did find for QT as well are pre-defined constants to different paths e.g. for the start menu:

UserStartMenuProgramsPath
AllUsersStartMenuProgramsPath

What I did NOT find yet is if there's some automatic mode like Inno provided? Something like a simple setting telling the installer to prefer system-wide start menu and stuff always, really everything which the installer is able to distinguish. Or do developers need to build proper paths on their own? Like in the following example:

component.addOperation("CreateShortcut", "@TargetDir@/pgmodeler.exe", "@StartMenuDir@/pgModeler.lnk"

vs.

component.addOperation("CreateShortcut", "@TargetDir@/pgmodeler.exe", "@AllUsersStartMenuProgramsPath@/@StartMenuDir@/pgModeler.lnk"

In the case of the latter, how does one switch between per-user and system-wide Programs and Features in the control panel as well?

Thanks!

1条回答
做个烂人
2楼-- · 2020-05-06 17:57

Switching between installation for current and all users can be done using a setting called AllUsers, which supports true and false. The important things are where and when to provide that: One way is really early when invoking the installer using the following:

installer.exe AllUsers=true

That way the GUI to select a start menu group really already shows all entries available to all users, not only those of the user-private start menu, like has been before. Another way is setting values on the installer at runtime. But it's important that this needs to happen BEFORE paths get resolved as well. An example can be seen at the following place:

function Controller()
{
    [...]
        //store all users and online/offline info
        installer.setValue("allUsers", isAdmin ? "true" : "false");
        installer.setValue("isOffline", installer.isOfflineOnly() ? "true" : "false");
    [...]
}

https://github.com/Skycoder42/QtIFW-Advanced-Setup/blob/master/installer/config/controller.js

These things have been enhanced in the past as well, even though I didn't find any explanation about what exactly and how to use it in the docs yet.

https://bugreports.qt.io/browse/QTIFW-124

Additionally, the software is not properly registered in Programs and Features, it only occurs admin-only:

Programs and features Admin Programs and features non-Admin

查看更多
登录 后发表回答