1

Using QtIFW-1.5.0, so far I'm able to generate an online installer for my Qt application on Windows. The installer downloads the appropriate package from my web server and performs some operations defined in the control script installscript.qs, e.g. writing some keys into registry and creating a desktop shortcut with an icon:

installscript.qs:

Component.prototype.createOperations = function()
{
    try
    {  
        // call the base create operations function
        component.createOperations();

        // Add some keys to registry;    
        var userProfile = installer.environmentVariable("USERPROFILE");
        installer.setValue("UserProfile", userProfile);
        var reg = installer.environmentVariable("SystemRoot") + "\\System32\\reg.exe";
        var key= "HKCU\\Software\\Company\\Product";
        component.addOperation("Execute", reg, "ADD", key, "/f");
        component.addOperation("Execute", reg, "ADD", key, "/v", "productId", "/t", "REG_BINARY");

        // Add a desktop shortcut with icon:
        component.addOperation("CreateShortcut",
                               "@TargetDir@\\MyExecutable.exe", 
                               "@UserProfile@\\Desktop\\MyExecutable.lnk",
                               "workingDirectory=@TargetDir@", 
                               "iconPath=@TargetDir@\\MyIcon.ico");
    }
    catch (e)
    { 
        print(e);
    }
}

All right, but another key I need to write into registry is the package VERSION NUMBER, defined in the installer configuration file config.xml in tag

<Version></Version>

How can I get this value from installscript.qs ? I read --I'd said more: studied-- the docs component QML Type and installer QML Type and I have not found any reference to version, except:

installer QML type:

boolean versionMatches(string version, string requirement)

which is useless for me, because you have to know the version, which is precisely what I find.

So any help would be appreciated.

Laura
  • 193
  • 12

1 Answers1

1

You can call

var version = installer.value("ProductVersion");

to get the version specified in the config.xml file.

Dávid Kaya
  • 924
  • 4
  • 17
  • Thanks, it works. Do you have any quick guide with the variables accessible from the installation script? – Laura Apr 09 '15 at 14:02
  • @Laura https://doc.qt.io/qtinstallerframework/scripting.html#predefined-variables – Dávid Kaya Apr 09 '15 at 16:33
  • I have read this documentation dozens of times without seeing it! Thank You. – Laura Apr 10 '15 at 07:16
  • Well, it works, but not as expected. I need the PACKAGE version of download package, which changes with each update. The ProductVersion doesn't change with updates, since it depends on the maintenance tool created by installer. – Laura Apr 17 '15 at 16:15