Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Qt Installer Framework and execution



  • Hello!
    I study how Installer Framework works and found the following thing: during the installation I have tried to install C++ redistributable and it was successfully done. The following code in installscript.qs does the job:

    // Check if redistributable is installed
    var registryVC2017x64 = installer.execute("reg", new Array("QUERY", "HKEY_LOCAL_MACHINE\\SOFTWARE\\Wow6432Node\\Microsoft\\VisualStudio\\14.0\\VC\\Runtimes\\x64", "/v", "Installed"))[0];
    
    if (!registryVC2017x64) {
    	component.addElevatedOperation("Execute", "@TargetDir@/vc_redist.x64.exe", "/passive", "/norestart");
    }
    

    Then I have tried to install more: I took libusb-win32 driver that has been generated with the wizard:

    component.addElevatedOperation("Execute", "@TargetDir@/Driver/InstallDriver.exe");
    

    Driver's installer window opens, installation goes successful as well, but then I receive the following error:

    Error during installation process (myPackage):
    Execution failed (Unexpected exit code: 256): "PathToInstallDriver"
    

    So my question is: can I somehow process return codes of executions in installscript.qs. Or should I do something with executable (driver installer in my case) to return correct code?



  • @St-Stanislav I have found the same topic with no solution:
    https://forum.qt.io/topic/56816/qt-ifw-addoperation-reporting-error
    And something similar here:
    https://forum.qt.io/topic/101441/how-can-i-detect-the-addoperation-error-in-installer-script

    I have opened the appropriate bug ticket in libusb-win32 branch, but anyway there should be some way to check and process exit statuses in QInstaller.



  • vcredist/meta/installscript.qs

    function Component(){}
    Component.prototype.createOperations = function()
    {
        component.createOperations();
        if (systemInfo.productType === "windows")
        {
            // return value 3010 means it need a reboot, but in most cases it is not needed for running Qt application
            // return value 5100 means there's a newer version of the runtime already installed
            component.addOperation("Execute", "{0,3010,1638,5100}", "@TargetDir@\\vc_redist.x64.exe", "/quiet", "/norestart");
            component.addOperation("Delete", "@TargetDir@\\vc_redist.x64.exe");
        }
    }
    

    vcredist/meta/package.xml

    <?xml version="1.0" encoding="UTF-8"?>
    <Package>
        <DisplayName>Microsoft Visual C++ 2015 Redistributable (x64)</DisplayName>
        <Description>Microsoft Visual C++ 2015 64位可再发行安装包</Description>
        <Version>14.0.24215.1</Version>
        <ReleaseDate>2020-05-19</ReleaseDate>
        <Default>true</Default>
        <ForcedInstallation>true</ForcedInstallation>
        <Script>installscript.qs</Script>
    </Package>
    

    driver/meta/installscript.qs

    function Component(){}
    Component.prototype.createOperations = function()
    {
        component.createOperations();
    
        if (systemInfo.productType === "windows")
        {
            component.addElevatedOperation("Execute", "{0,1,256}", "@TargetDir@\\InstallDriver.exe");
            component.addElevatedOperation("Delete", "@TargetDir@\\InstallDriver.exe");
        }
    }
    

    driver/meta/package.xml

    <?xml version="1.0" encoding="UTF-8"?>
    <Package>
        <DisplayName>driver</DisplayName>
        <Description>driver</Description>
        <Version>1.0.1</Version>
        <ReleaseDate>2020-07-11</ReleaseDate>
        <Default>true</Default>
        <ForcedInstallation>true</ForcedInstallation>
        <Script>installscript.qs</Script>
        <RequiresAdminRights>true</RequiresAdminRights>
    </Package>
    


  • @abc881858 thank you king <3


Log in to reply