[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.
-
@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.
-
@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?
-
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");