Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt Creator and other tools
  4. Qt Installer Framework and execution

Qt Installer Framework and execution

Scheduled Pinned Locked Moved Unsolved Qt Creator and other tools
4 Posts 3 Posters 2.6k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    St.Stanislav
    wrote on last edited by
    #1

    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?

    S 1 Reply Last reply
    0
    • S St.Stanislav

      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?

      S Offline
      S Offline
      St.Stanislav
      wrote on last edited by
      #2

      @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.

      1 Reply Last reply
      1
      • A Offline
        A Offline
        abc881858
        wrote on last edited by
        #3

        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>
        
        S 1 Reply Last reply
        2
        • A abc881858

          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>
          
          S Offline
          S Offline
          Skeird
          wrote on last edited by
          #4

          @abc881858 thank you king <3

          1 Reply Last reply
          0

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved