问题
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