[SOLVED] IFW - How to set "run as administrator" flag on maintenancetool during install
-
wrote on 30 Jul 2015, 13:04 last edited by Hertzy 8 May 2015, 13:28
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?
-
wrote on 31 Jul 2015, 11:09 last edited by Hertzy
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.
-
wrote on 31 Jul 2015, 11:32 last edited by
Not sure, but I would expect regedit.exe instead of reg.exe.
-
wrote on 31 Jul 2015, 13:43 last edited by 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.
-
@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.
wrote on 31 Jul 2015, 14:11 last edited by@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?
-
wrote on 31 Jul 2015, 14:20 last edited by
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.
-
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.
-
wrote on 3 Aug 2015, 11:31 last edited by
I have made some progress. Appears that reg.exe helpfully placed the entries into HKLM\SOFTWARE\Wow6432Node\ instead of where I told it to.
-
wrote on 3 Aug 2015, 14:26 last edited by Hertzy 8 Mar 2015, 14:27
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");
6/9