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



  • 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?



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


  • Moderators

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



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


  • Moderators

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



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


  • Moderators

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



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



  • 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");
    

Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.