0

My installer sets a compatibility mode for an app via registry (for all users):

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers]
"C:\\Program Files (x86)\\Program\\Program.exe"="RUNASADMIN"

Windows 10 ignores this, though, - no UAC prompt until I open properties/compatibility tab, manually deselect "run as admin", and select it back. Another solution is to create an registry entry for the current user as well:

[HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers]
"C:\\Program Files (x86)\\Program\\Program.exe"="RUNASADMIN"

Why is this? I've had no problems with creating only HKLM registry keys under Win 7 - the system has always recognized the needed compatibility options.

phuclv
  • 37,963
  • 15
  • 156
  • 475
Demeter
  • 9
  • 3
  • Are those registry keys officially documented to do what you need? – IInspectable Mar 20 '16 at 17:08
  • No, but they're being widely used (by GOG in their installers, for example). Also, the keys were discussed on this site: http://stackoverflow.com/questions/2313045/how-to-set-run-this-program-as-an-administrator-programatically – Demeter Mar 20 '16 at 17:16
  • Why do you expect Microsoft to not break a contract they never signed? Any reason you aren't going the documented route, and use an application manifest instead (e.g. by using the [/MANIFESTUAC (Embeds UAC information in manifest)](https://msdn.microsoft.com/en-us/library/bb384691.aspx) linker option)? – IInspectable Mar 20 '16 at 17:22
  • I didn't expect anything. I'm just curious, if the change is intended or is a bug. And yes, the solution you described most likely is the best. – Demeter Mar 20 '16 at 17:28
  • The change is intended (likely), and certainly not a bug. It changes an implementation detail, not a published contract. With few exceptions, the registry is not an official programming interface. – IInspectable Mar 20 '16 at 17:32
  • 1
    If you need to set compatibility flags for an application you can use the Microsoft Application Compatibility Toolkit to create an .sdb file which can be installed via the `sdbinst` command. (But in this particular case, and assuming you are able to rebuild the executable in question, you should use a manifest as IInspectable suggests.) – Harry Johnston Mar 20 '16 at 21:57
  • Thanks for the answers guys. – Demeter Mar 20 '16 at 23:30

1 Answers1

0

It may be that do what you are doing you need to add ~ and a space. As in "~ RUNASADMIN". This worked for me. There is more discussion on this at Windows Ten Forums.

Will
  • 337
  • 4
  • 15