Qt Installer Framework - Create shortcut in Start Menu for all users

依然范特西╮ 提交于 2020-01-03 08:57:14

问题


With the installer framework I would like to create an installer for my application. The application is installed by the administrator on the PC. The application is then used by different users.

In the installer I create shortcuts from executable to start menu.

This is accomplished in the installscript.js by the command:

component.addOperation(“CreateShortcut”, “@TargetDir@/application.exe”, 
“@StartMenuDir@/Name of Application.lnk”, “workingDirectory=@TargetDir@”);

The problem now, is that the installer creates shortcut in the start menu only for the current user, e.g. the Administrator.

Also, the uninstall program is visible only for the current user. When I log with another user, the application is not visible in the start menu.

How is it possible to generate a shortcut, which is visible in the start menu for all users?


回答1:


Try

component.addOperation("CreateShortcut", "@TargetDir@/application.exe", "C:\\ProgramData\\Microsoft\\Windows\\Start Menu\\Programs\\<Name of Application>.lnk");

In fact, there is a variable AllUsersStartMenuProgramsPath available but I have just tried it and it seems to be broken. Links are put in C:\ by using it.

Like installer.value("os"), you should use installer.value("AllUsersStartMenuProgramsPath") in your script.

See the lastest documentation : http://doc-snapshot.qt-project.org/qtifw-master/scripting.html

I think a bug should be opened on their bug tracker : https://bugreports.qt-project.org/secure/Dashboard.jspa




回答2:


This works for me:

Component.prototype.createOperations = function()
{
    component.createOperations();
    console.log("creating start menu entries");
    if (systemInfo.productType === "windows") {
        component.addOperation("Mkdir", "@StartMenuDir@")
        component.addOperation("CreateShortcut", "@TargetDir@/README.txt", 
            "@StartMenuDir@/README.lnk",
            "workingDirectory=@TargetDir@", 
            "iconPath=%SystemRoot%/system32/SHELL32.dll",
            "iconId=2", "description=Open README file");
    }
}

Note that the script creates the according start menu directory before creating the shortcuts.



来源:https://stackoverflow.com/questions/24505642/qt-installer-framework-create-shortcut-in-start-menu-for-all-users

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!