Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Qt Installer Framework and Administrator privileges [SOLVED]
Forum Update on Tuesday, May 27th 2025

Qt Installer Framework and Administrator privileges [SOLVED]

Scheduled Pinned Locked Moved General and Desktop
44 Posts 15 Posters 39.5k Views 1 Watching
  • 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.
  • E Offline
    E Offline
    exiBob
    wrote on last edited by
    #12

    My apologies, I did actually write it using the syntax above at first but 'tinkered' with it a little when it was not working. I must have then copy pasted the wrong(changed) code into this post window.

    I still cannot get the drivers to install using either of the script calls. Using the first syntax the software does install but the drivers do not, there are no error messages and the install log states-

    backup com.exi.root operation: Execute

    • arguments: cmd /C "C:\Users\Bobby\SFC4000\USB_Install.bat"
      Done
      perform com.exi.root operation: Execute
    • arguments: cmd /C "C:\Users\Bobby\SFC4000\USB_Install.bat"
      ElevatedExecuteOperation setNativeArguments to start: "cmd /C "C:\Users\Bobby\SFC4000\USB_Install.bat""
      cmd /C "C:\Users\Bobby\SFC4000\USB_Install.bat"" started, arguments: "
      Done

    so it is calling the command correctly from the script yes?

    The second script call gives an error message-

    "Error during installation process(com.exi.root):
    Execution faild(Unexpected exit code: 1): "cmd /C "C:
    \Users\Bobby\SFC4000\USB_Install.bat""

    I'm sure I'm just doing something stupid but i just can't see it. Thanks for your help.

    1 Reply Last reply
    0
    • A Offline
      A Offline
      amahta
      wrote on last edited by
      #13

      Oh, I see. I also noticed it now, you are trying to run a bat file. Did you set workingDirectory parameter to the folder in which your bat file exists?

      My only suggestion would be to go for all of the solutions above at once. :)

      Add this to your package
      @
      <RequiresAdminRights>true</RequiresAdminRights>
      @

      And call elevated version of the function like this (Also set working directory)
      @
      component.addElevatedOperation("Execute", "cmd /C "@TargetDir@\USB_Install.bat"", "workingDirectory=@TargetDir@");
      @

      If this also doesn't work then you can share the contents of your bat file.
      Maybe that way I can understand a little bit more about the issue you're facing.

      Thou shalt programme
      http://www.amin-ahmadi.com

      1 Reply Last reply
      0
      • E Offline
        E Offline
        exiBob
        wrote on last edited by
        #14

        Thank you very much for your help. It's much appreciated. Unfortunately it is still not working. However it does not produce a different error-

        "Execute" as admin: true
        backup com.exi.root operation: Execute

        • arguments: cmd /C "C:\Users\Bobby\SFC4000\USB_Install.bat", workingDirectory=C:\Users\Bobby\SFC4000
          Done
          perform com.exi.root operation: Execute
        • arguments: cmd /C "C:\Users\Bobby\SFC4000\USB_Install.bat", workingDirectory=C:\Users\Bobby\SFC4000
          ElevatedExecuteOperation setWorkingDirectory: "C:\Users\Bobby\SFC4000"
          ElevatedExecuteOperation setNativeArguments to start: "cmd /C "C:\Users\Bobby\SFC4000\USB_Install.bat""
          cmd /C "C:\Users\Bobby\SFC4000\USB_Install.bat"" started, arguments: "
          Done
          Operation 'Execute' with arguments: 'cmd /C "C:\Users\Bobby\SFC4000\USB_Install.bat"; workingDirectory=C:\Users\Bobby\SFC4000' failed: Execution failed: Could not start: "cmd /C "C:\Users\Bobby\SFC4000\USB_Install.bat""(Process failed to start: The parameter is incorrect.)
          created warning message box installationErrorWithRetry: 'Installer Error', Error during installation process (com.exi.root):
          Execution failed: Could not start: "cmd /C "C:\Users\Bobby\SFC4000\USB_Install.bat""(Process failed to start: The parameter is incorrect.)

        I don't think it is the actual batch file that's the problem as it runs fine when called directly from the administrator command prompt but it is show below anyway.

        @
        @echo off

        rundll32.exe libusb0.dll,usb_install_driver_np_rundll sfc3000.inf
        @

        1 Reply Last reply
        0
        • A Offline
          A Offline
          amahta
          wrote on last edited by
          #15

          I can see a very familiar error message there:
          "Process failed to start: The parameter is incorrect"

          Try this and share the results if you can.

          Press WIN + R to open "Run" program
          Enter the following line as a command and see what happens:
          cmd /C “C:\Users\Bobby\SFC4000\USB_Install.bat”

          As far as I know, if it runs using Run application then it will surely run using your installer too.
          If it doesn't run using Run application then you shouldn't mess around with installer much and try to correct your batch script.

          What about this, don't turn off echo and insert a pause at the of your batch script. Like this:
          @
          rundll32.exe libusb0.dll,usb_install_driver_np_rundll sfc3000.inf
          pause
          @

          Thou shalt programme
          http://www.amin-ahmadi.com

          1 Reply Last reply
          0
          • A Offline
            A Offline
            amahta
            wrote on last edited by
            #16

            Also share the result you see in the command window

            Thou shalt programme
            http://www.amin-ahmadi.com

            1 Reply Last reply
            0
            • E Offline
              E Offline
              exiBob
              wrote on last edited by
              #17

              ECHO is on.

              It was originally calling the batch file from the system32 directory so I added a call to cd and now change it to the .bat's current dir and slightly modified the folder layout and updated the batch file accordingly. This is was cmd window prints out

              C:\Windows\system32>cd C:\Users\Bobby\SFC4000\

              C:\Users\Bobby\SFC4000>cd ".\Driver\exi"

              C:\Users\Bobby\SFC4000\Driver\exi>rundll32.exe libusb0.dll,usb_install_driver_np
              _rundll sfc3000.inf

              C:\Users\Bobby\SFC4000\Driver\exi>pause
              Press any key to continue . . .

              1 Reply Last reply
              0
              • A Offline
                A Offline
                amahta
                wrote on last edited by
                #18

                Sorry I didn't get it. Is this the output for Installer running your batch or is this the result for Run application???
                There are no errors here, if you're saying that it ran just fine when you tried it with Run then it seems we're stuck at this point!
                My advice would be to check the scripts again one more time and if you are 100% sure that it just isn't working for you then try another installer creator (like inno setup) for the time being. Until new release for QTIFW comes out.

                Thou shalt programme
                http://www.amin-ahmadi.com

                1 Reply Last reply
                0
                • E Offline
                  E Offline
                  exiBob
                  wrote on last edited by
                  #19

                  That was the output in the command window when using your win+r instructions.

                  Its OK now though I finally have it working!! I applied all of the changes that you suggested and also changed the installer compatibility settings in it's properties so that it's run as administrator. I probably would have got it working much sooner if i hadn't spent an hour or so trying to install the 32bit drivers on my 64bit machine DUHHHH! But hey, we live and learn.

                  Thanks for your help really appreciate it :)

                  1 Reply Last reply
                  0
                  • A Offline
                    A Offline
                    amahta
                    wrote on last edited by
                    #20

                    :) Wow. Ok. Glad to hear you made it work finally.

                    Thou shalt programme
                    http://www.amin-ahmadi.com

                    1 Reply Last reply
                    0
                    • N Offline
                      N Offline
                      nwoki
                      wrote on last edited by
                      #21

                      Hi, sorry to bring this post back to life, but I'm having problems executing a bundled installer from the installscript.qs in my QtInstaller application.

                      What I do is install the .msi to the @TargetDir@ and then try to launch it with

                      @component.addOperation("Execute", "msiexec.exe /i", ""@TargetDir@\MyUsbDriver.msi"");@

                      (I used the double quotes for the target dir because my installer application can accept paths with spaces, I'm installing on wnidows)

                      I keep on getting error messages stating:

                      bq. Execution Failed: Could not start: "C:\Program Files\MyApp\MyUsbDriver.msi" (Process failed to start: The parameter is incorrect)
                      (I used the double quotes for the target dir because my installer application can accept paths with spaces, I'm installing on wnidows)

                      Any ideas on how to correctly launch the .msi file?

                      1 Reply Last reply
                      0
                      • A Offline
                        A Offline
                        amahta
                        wrote on last edited by
                        #22

                        [quote author="amahta" date="1390477421"]To be precise, this is how I solved my problem because I was working on Windows and if you are also on Windows, I suggest you also do this and skip all the complications:
                        @
                        Component.prototype.createOperations = function()
                        {
                        try
                        {
                        // call the base create operations function
                        component.createOperations();
                        if (installer.value("os") === "win")
                        {
                        component.addOperation("Execute", "cmd /C "@TargetDir@\SomeFolder\SomeFile.exe"");
                        }
                        } catch (e)
                        {
                        print(e);
                        }
                        }
                        @
                        You don't need to add admin rights for this to work.
                        Just let the command prompt do the job for you :)[/quote]

                        This should work for you. Pass your msi file using "msiexec" command to "cmd"

                        Thou shalt programme
                        http://www.amin-ahmadi.com

                        1 Reply Last reply
                        0
                        • N Offline
                          N Offline
                          nwoki
                          wrote on last edited by
                          #23

                          Using

                          @component.addOperation("Execute", "cmd /C", "msiexec.exe /i", ""@TargetDir@\MyUsbDriver.msi"");
                          @

                          gives me the same execution error stated above.

                          Running the command from cmd starts the driver installation though. So it's got to be something in the installscript.qs.

                          Any ideas?

                          1 Reply Last reply
                          0
                          • S Offline
                            S Offline
                            sandeepsastry
                            wrote on last edited by
                            #24

                            I have a related issue and am struggling to get it going for quite sometime. I have even raised a jira on Qt Installer Framework https://bugreports.qt-project.org/browse/QTIFW-497 but did not get a reply/comment yet. Any pointers would be of great help.

                            1 Reply Last reply
                            0
                            • W Offline
                              W Offline
                              wesblake
                              wrote on last edited by
                              #25

                              [quote author="nwoki" date="1398777153"]Using

                              @component.addOperation("Execute", "cmd /C", "msiexec.exe /i", ""@TargetDir@\MyUsbDriver.msi"");
                              @

                              gives me the same execution error stated above.

                              Running the command from cmd starts the driver installation though. So it's got to be something in the installscript.qs.

                              Any ideas?[/quote]

                              Hi, I have a similar issue to this thread, and closer to that quoted above. I've looked everywhere and can find threads about executing exe's, etc AFTER installation of my own app, but need to know how to install a prerequisite for my app. This is common functionality in other installers but I can't seem to find info on it for QT Installer Framework.
                              I.E., I need to first run vcredist_x86.exe or my program will not work. Better yet would be detecting if they already have that or not (other advanced installer I've seen do this) and launch accordingly, but even as simple launch before we install ours would work ok too. Can this be done?

                              1 Reply Last reply
                              0
                              • N Offline
                                N Offline
                                nwoki
                                wrote on last edited by
                                #26

                                Forgot to post my answer. This is how i resolved my problem. Basically, every parameter must be seperated as follows

                                @ component.addOperation("Execute"
                                , "msiexec"
                                , "/i"
                                , "@TargetDir@\Driver.msi"
                                , "UNDOEXECUTE"
                                , "msiexec"
                                , "/qb"
                                , "/x"
                                , "@TargetDir@\Driver.msi");@

                                1 Reply Last reply
                                0
                                • B Offline
                                  B Offline
                                  blackpainter
                                  wrote on last edited by
                                  #27

                                  Hello Everyone,

                                  I hate to warm this up, but i am encountering the same problems.
                                  I need to install some drivers along with my software, which need admin rights for installment.

                                  All together i added:
                                  @<RequiresAdminRights>true</RequiresAdminRights> @
                                  to the package.xml
                                  and
                                  @function Component()
                                  {
                                  }

                                  Component.prototype.createOperations = function()
                                  {
                                  try
                                  {
                                  installer.gainAdminRights();
                                  component.createOperations();
                                  if (installer.value("os") === "win")
                                  {
                                  // component.addElevatedOperation("Execute", "cmd", "/C", ""@TargetDir@\CP210xVCPInstaller_x64.exe"", "workingDirectory=@TargetDir@");
                                  component.addElevatedOperation("Execute", "{256}", ""@TargetDir@\CP210xVCPInstaller_x64.exe"", "workingDirectory=@TargetDir@");
                                  }
                                  } catch (e)
                                  {
                                  print(e);
                                  }
                                  }@

                                  This returns the error:
                                  @Error during installation process (driver_x64):
                                  Execution failed(Unexpected exit code: 0): ""[Filepath]""@

                                  The returncode is not the issue. it does not even start the driver installation.
                                  I tried the cmd version also, but could not get it to work either.

                                  When i manually start the installer with admin rights, it works fine.

                                  Any advice? Thanks in advance.

                                  1 Reply Last reply
                                  0
                                  • T Offline
                                    T Offline
                                    trallallero
                                    wrote on last edited by
                                    #28

                                    Hi all and thanks for the hints.
                                    I've found a problem related to admin rights so I write here instead of opening a new thread.

                                    I created a "TestInstaller" that installs a "qt hello world" program to "Program Files (86)/TestInstaller" with admin privileges.

                                    Then if I uninstall it using admin privileges, the directory "Program Files (86)/TestInstaller" is deleted as it should.

                                    If I uninstall it NOT using admin privileges, the directory is not deleted and still contains the file "uninstall.exe".

                                    How can I fix this ?

                                    1 Reply Last reply
                                    0
                                    • N Offline
                                      N Offline
                                      nwoki
                                      wrote on last edited by
                                      #29

                                      You can't. It's a know bug bug nobody has picked it up at the moment.

                                      https://bugreports.qt-project.org/browse/QTIFW-447?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel

                                      1 Reply Last reply
                                      0
                                      • T Offline
                                        T Offline
                                        trallallero
                                        wrote on last edited by
                                        #30

                                        I tried to post a thanks to nwoki the 1 October but the forum was presumably down as I could not.
                                        Thanks.

                                        Anyway, I have other problems now: beside the logo not shown, I need to create an installer for a customer and it should NOT have admin rights.
                                        So I wrote
                                        <RequiresAdminRights>false</RequiresAdminRights>
                                        in package.xml, I DON'T call
                                        installer.gainAdminRights();
                                        but when I execute the created installer, the admin password is asked.
                                        Another bug or what ?
                                        I have a Qt license, shall I contact the support ?

                                        1 Reply Last reply
                                        0
                                        • W Offline
                                          W Offline
                                          Wilmord
                                          wrote on last edited by
                                          #31

                                          @amahta said:

                                          TargetDir

                                          Hello All,

                                          Actually, I have a same problem ( using 2.0.0 version), I want to use this command below:

                                          component.addElevatedOperation("Execute", "{0,3010}", "@TargetDir@\vcredist\vcredist_x86.exe", "/norestart", "/q");

                                          But It crashes when installing process. In my package.xml, <RequiresAdminRights>true</RequiresAdminRights> tag is exist.

                                          Thanks in advance.

                                          A 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