11

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?

Stein Åsmul
  • 39,960
  • 25
  • 91
  • 164
user3793032
  • 111
  • 1
  • 3

2 Answers2

6

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

MBach
  • 1,647
  • 16
  • 30
  • I tested this today and the AllUsersStartMenuProgramsPath variable works fine as long as I use it in the installer.value() function as you described. "@AllUsersStartMenuProgramsPath@/foo.lnk" however does not work. – Herr von Wurst Dec 04 '18 at 09:21
  • Does that address entries in `Programs and Features` in the control panel of Windows as well? – Thorsten Schöning Dec 28 '19 at 12:15
1

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.

Herr von Wurst
  • 2,571
  • 5
  • 32
  • 53
  • I fact this does not create an entry for all users, I misread the question. I'm leaving this here in case it helps anyone else anyways. – Herr von Wurst Dec 04 '18 at 08:36