Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Installation and Deployment
  4. [SOLVED] IFW - How to set "run as administrator" flag on maintenancetool during install

[SOLVED] IFW - How to set "run as administrator" flag on maintenancetool during install

Scheduled Pinned Locked Moved Installation and Deployment
scriptifw
9 Posts 2 Posters 4.8k 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.
  • H Offline
    H Offline
    Hertzy
    wrote on last edited by Hertzy
    #1

    Greetings,

    I'm currently faced with the problem described in bug QTIFW-759, namely that running maintenancetool without admin privileges blanks the installation directory and then fails due to not having write permissions.

    I believe that an acceptable workaround would be to set the "Run as administrator" flag on maintenancetool.exe in an install script. However, I can't seem to find in the documentation on install scripts as to how this would be done. Is this a workable solution, and if yes, how would I do it?

    1 Reply Last reply
    0
    • H Offline
      H Offline
      Hertzy
      wrote on last edited by Hertzy
      #2
      var reg = installer.environmentVariable("SystemRoot") + "\\System32\\reg.exe";
      var key= "HKLM\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\AppCompatFlags\\Layers" ;
      component.addOperation("Execute", reg, "ADD", key, "/v", "@TargetDir@\\maintenancetool.exe", "/t", "REG_SZ", "/d","~ RUNASADMIN", "/f");
      

      should achieve this, but for some reason doesn't.

      1 Reply Last reply
      0
      • K Offline
        K Offline
        koahnig
        wrote on last edited by
        #3

        Not sure, but I would expect regedit.exe instead of reg.exe.

        Vote the answer(s) that helped you to solve your issue(s)

        H 1 Reply Last reply
        0
        • K koahnig

          Not sure, but I would expect regedit.exe instead of reg.exe.

          H Offline
          H Offline
          Hertzy
          wrote on last edited by Hertzy
          #4

          @koahnig That would require editing the maintenancetool path into the registration file being fed to regedit.exe durin installation.

          reg.exe is a command line tool that carries out the registration operation perfectly well when executed in an administrator-privileged command prompt. For whatever reason, it doesn't write the registry when it's executed during the install script. Giving it bogus parameters in the install script gives an error dialog, too.

          EDIT to add: using addElevatedOperation doesn't seem to help, either.

          K 1 Reply Last reply
          0
          • H Hertzy

            @koahnig That would require editing the maintenancetool path into the registration file being fed to regedit.exe durin installation.

            reg.exe is a command line tool that carries out the registration operation perfectly well when executed in an administrator-privileged command prompt. For whatever reason, it doesn't write the registry when it's executed during the install script. Giving it bogus parameters in the install script gives an error dialog, too.

            EDIT to add: using addElevatedOperation doesn't seem to help, either.

            K Offline
            K Offline
            koahnig
            wrote on last edited by
            #5

            @Hertzy said:

            @koahnig That would require editing the maintenancetool path into the registration file being fed to regedit.exe durin installation.

            Thanks for clarification. Obviously you have more experience there than I do. I am appreciating your summaries on this topic as on other stuff for ifw. It is really hard to find details. Without scripting knowledge it is hopeless.

            BTW what version of IFW are you using?

            Vote the answer(s) that helped you to solve your issue(s)

            1 Reply Last reply
            0
            • H Offline
              H Offline
              Hertzy
              wrote on last edited by
              #6

              I'm using version 2.0.1. I'm considering using a nightly snapshot to see if it isn't fixed in one of those.

              K 1 Reply Last reply
              0
              • H Hertzy

                I'm using version 2.0.1. I'm considering using a nightly snapshot to see if it isn't fixed in one of those.

                K Offline
                K Offline
                koahnig
                wrote on last edited by
                #7

                @Hertzy
                OK, I started to use IFW end of May. Apparently, IFW 2.0 was very fresh. A lot of reference in documentation were not even showing that there is a newer version. It looks like I am using IFW 2.0.0.

                Vote the answer(s) that helped you to solve your issue(s)

                1 Reply Last reply
                0
                • H Offline
                  H Offline
                  Hertzy
                  wrote on last edited by
                  #8

                  I have made some progress. Appears that reg.exe helpfully placed the entries into HKLM\SOFTWARE\Wow6432Node\ instead of where I told it to.

                  1 Reply Last reply
                  0
                  • H Offline
                    H Offline
                    Hertzy
                    wrote on last edited by Hertzy
                    #9

                    At last I got it to work. The parameter "/reg:64" passed to reg.exe makes it do what it's told. I just hope this won't mess things up on a 32bit windows.

                    So, that needs to be

                    component.addElevatedOperation("Execute",reg, "ADD",key, "/reg:64" ,"/v","@TargetDir@\\maintenancetool.exe","/t","REG_SZ","/d","~ RUNASADMIN", "/f");
                    
                    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