I tried the options listed in the other Questions, the registry settings and the 'change a bit' in the executable. But neither seems to work in the latest Windows 10 builds. The HKLM and HKLU have the same entries indicating the program is to 'run as administrator'. If I manually select 'Run as administrator' the program operates correctly. By correctly, I mean it reads its Registry keys correctly, otherwise it seems not to find the keys. I was not using the '~', so I added the '~' and it seems to have other problems reading it registry keys; "This key is already associated with an element of the collection."
The Properties of the file do not reflect the 'Run As Administrator' setting. That is the check-box is not selected even though the registry values are set. If I set the 'check-box' myself the program runs correctly. In the registry it shows '~ RUNASADMIN'.
Setting the registry seemed to work ok for Windows 10 from @2016.
In the Registry there is another group called 'Compatibility Assistant'-'Store'. In that folder there are other references to my program and then a block of some binary data. Looks to be 94hex bytes long.
Am I supposed to doing something with those as well?
I am using the following code:
Root: HKCU; Subkey: "SOFTWARE\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers"; ValueType: multisz; \
ValueName: "{#InstallFolder}\myapp.exe"; ValueData: "RUNASADMIN"; \
Flags: uninsdeletekeyifempty uninsdeletevalue; MinVersion: 0,6.2
I then write the same information to HKLM. (Which does not appear to be written at all.)
myapp.exe is a VB6 program from the early 2000's I do not think there's an app.manifest file.
The 'other questions': How to set 'Run as administrator' on a file using Inno Setup The second answer mentions running an Inno function after installing the item and it appears to me that that function is setting a byte in the file.
Stream.ReadBuffer(Buffer, 1);
Buffer[1] := Chr(Ord(Buffer[1]) or $20);
Stream.Seek(-1, soFromCurrent);
Stream.WriteBuffer(Buffer, 1);
After some further testing this is what I have found. It looked like the manifest was working. (By working I mean reading and writing the HKLM-WOW6432Node keys the programs use to share some settings.) I renamed the manifest to prove it was doing something, and it appeared to be. I created an AppCompatFlag set to runasadmin, that appeared to work. I removed the key and it did not work; as expected, I put the key back and the manifest back but neither appear to work; the program is reading and writing to the Virtual Store keys and not the HKLM-WOW6432Nodes keys.
What it looks like is happening is the first time the program runs, there's no virtual store so it reads from the HKLM key, that makes the program look like it is working. But then when I change a setting it writes to the virtual store key and not the HKLM-WOW6432Node key. Then after that it always reads from the virtual store key and completely ignores the HKLM key. I have the manifest and the AppCompatFlags all set to 'runasadmin' and the icon has the UAC shield. If I delete the Virtual Store keys, the program reads from the HKLM-WOW6432Node keys, but the writes always go to the Virtual Store keys.
If I explicitly 'run as admin' from the 'right-click' menu then it reads from and writes to the HKLM-WOW6432Node keys as desired. So maybe it looked like it worked because all the program was redirected to the Virtual store keys. As soon as one program was 'run as admin' (from the right-click menu) that program would only read from the HKLM-WOW6432Node keys and that would then fail. What's also odd is that one program will read from the Virtual Store keys, but another program still reads from the HKLM-WOW6432Node keys. Both programs are signed... Maybe I've got too many things indicating 'run as administrator'. I also had WINXPSP3 mode selected, maybe that was causing the redirects.