The administrator flag does end up there too, and is called RUNASADMIN
.
To programatically set application compatibility settings in Windows, add a registry value to one of the following locations:
HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers
(For the current user only)
HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers
(For all users on the system)
The registry value should have the full path to the executable as the name, be of the REG_SZ
type, and contain a space-separated list of compatibility flags as the data. Up to 3 different compatibility settings can be configured:
Privilege Level:
RUNASADMIN
- Runs the program with the administrative security token
Display Settings:
DISABLETHEMES
- Disable Visual Themes
640X480
- Run in 640 x 480 screen resolution
HIGHDPIAWARE
- Disable display scaling on high DPI settings
256COLOR
- Run in 256 colors
DISABLEDWM
- Disable Desktop Composition
Compatibility Mode:
WIN95
- Windows 95
WIN98
- Windows 98
WIN4SP5
- Windows NT 4.0 SP5
WIN2000
- Windows 2000
WINXPSP2
- Windows XP SP2
WINXPSP3
- Windows XP SP3
VISTARTM
- Vista
VISTASP1
- Vista SP1
VISTASP2
- Vista SP2
WIN7RTM
- Windows 7
WINSRV03SP1
- Windows Server 2003 SP1
WINSRV08SP1
- Windows Server 2008 SP1
Source
For example, the following flags an executable as requiring both administrative privileges and compatibility mode for Windows XP SP3:
reg.exe ADD "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers" /v "C:\temp\compatmodel\iconsext.exe" /t REG_SZ /d "WINXPSP3 RUNASADMIN" /f
To apply this remotely, either push out registry settings with group policy, remotely execute a command like the above, or enable the remote registry service and use that to apply the settings.