Uploaded image for project: 'Qt Installer Framework'
  1. Qt Installer Framework
  2. QTIFW-3848

AllUsers not working if set programmatically

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • Not Evaluated
    • None
    • 4.10
    • Translations, UI
    • None
    • Windows

    Description

      I manage the installation of a small application of mine on Windows using QtIFW.

      The following snippet of XML in the package.xml of one of the installed components sets a link to the application on the Desktop:

      <Operations>
        ...
        <Operation name="CreateShortcut">
          <Argument>@TargetDir@\LBChronoRace.exe</Argument>
          <Argument>@DesktopDir@\LBChronoRace.lnk</Argument>
          <Argument>workingDirectory=@TargetDir@</Argument>
          <Argument>iconPath=@TargetDir@\LBChronoRace.exe</Argument>
          <Argument>iconId=0</Argument>
          <!--<Argument>description="Start LBChronoRace"</Argument>-->
        </Operation>
        ...
      </Operations>

      The link is installed on the Desktop folder of the user that is installing the application.

      I would like the link to be installed in the Desktop directory common to all users. To achieve this I tried running the installer by adding AllUsers=true to its command line. And it worked.

      Since this is not feasible for those who will download and install the application (they will not be developers and will install with a simple double click), I tried setting AllUsers=true programmatically in the IFW control script:

      function Controller() {
          installer.setValue("AllUsers", "true");
      }

      But it doesn't work and the link keeps being created in the user's Desktop folder instead of the common folder.

      I have evidence that the variable is set. Infact in the last page of the installer the value is reported as true by the following snippet:

      I set
      Controller.prototype.FinishedPageCallback = function() {
          var allUsers = installer.value("AllUsers");
          var desktopDir = installer.value("DesktopDir");
          var page = gui.pageWidgetByObjectName("FinishedPage");
          if (page) {
              var msg = "AllUsers = " + allUsers + "\nDesktopDir = " + desktopDir;
              page.MessageLabel.setText(msg);
          }
      };

      Looking at the addDynamicPredefinedVariables() function of packagemanagercoredata.cpp I notice this:

      QString desktop;
      if (m_variables.value(QLatin1String("AllUsers")) == scTrue) {
          desktop = system.value(QLatin1String("Common Desktop")).toString();
      } else {
          desktop = user.value(QLatin1String("Desktop")).toString();
      }
      addNewVariable(QLatin1String("DesktopDir"), replaceWindowsEnvironmentVariables(desktop));
      

      So I don't understand why there should be a difference between when the variable set in the environment and when it is set programmatically.

      I also tried the same on the component script installscript.qs:

      function Component() {
      }
      
      Component.prototype.createOperations = function() {
          /* Set the variabile BEFORE operations creation */
          installer.setValue("AllUsers", "true");
      
          /* Go on with standard operations */
          component.createOperations();
      };

      with both

      <Script>installscript.qs</Script>

      and

      <Script postLoad="true">installscript.qs</Script>

      but without any change in the installer behaviour.

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            installerteam Installer Team
            flinco Lorenzo Buzzi
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes