Today someone in a forum asked how to programmatically configure an application so that it runs in compatibility mode. Configuring this manually is easy, just open the file’s properties, select the Compatibility tab and apply the required settings. On Windows 7 this then looks as shown in the picture below.
Now whatever we configure here, it all gets written to the following location in the Windows Registry:
If the settings have to apply for all users the information must be stored here:
When configuring compatibility mode settings for an application executable, shortcut or batch file, a registry string is created for each item.
For each application there are three settings that can be applied. The compatibility mode, (Display) Settings and the Privilege Level. One or multiple values can be set (separated by a space).
|WIN4SP5||Windows NT 4.0 SP5|
|WINXPSP2||Windows XP SP2|
|WINXPSP3||Windows XP SP3|
|WINSRV03SP1||Windows Server 2003 SP1|
|WINSRV08SP1||Windows Server 2008 SP1|
|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|
|RUNASADMIN||Run program as an administrator|
If the settings are written into the HKEY_LOCAL_MACHINE part of the registry, the settings cannot be changed by a user that has no local administrative rights.
The following registry command line applies Windows XP SP3 compatibility mode and defines the application to run as administrator.
REG ADD "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers" /v "C:\temp\compatmodel\iconsext.exe" /t REG_SZ /d "WINXPSP3 RUNASADMIN" /f
14 Replies to “Running an Application as Administrator or in Compatibility Mode”
I can’t install Visual Studio 2010 on my Windows Server 2003 machine because the OS is trying to run the setup.exe in compatibility mode even though no compatibility mode is set on that file (nothing is set on its compatibility tab). Is it possible to disable compatibility mode checking on Windows Server 2003?
This is the first solution I found that really works under 7, for a cmd file. The command line works great. Many thanks. Michel
Exactly what I was after! You listed all the available flags whereas everyone else just mentions the compatibility settings.
Thank you Sir!
Thank you for the info, this is just what I was looking for.
Do you know if it is possible to turn of the User Account approval prompt for a program that is given run as admin as per this post? This program has Microsoft certification.
When compatibility mode is set via Properties, Windoze places a tilde (~) followed by a space before the value, e.g. “~ WINXPSP3”. Yet it seems to work (or not work as the case may be) regardless of the tilde. So what is the function/meaning/purpose of the tilde?
Also, with Windows 10TP, programs run in compatibility mode if invoked with the “run” command or by clicking on the program name in explorer, but do NOT run in compatibility mode (or at all) from the command prompt!
Life saver stuff, man. Thank you very much for the info.
Thanks for this. This is good information. Does anybody know what a value of # represents? I noticed this on one of my clients.
Well, maybe could be helpful for someone, I used a batch file to set compatibility settings on all D:\ts* folders (used for an specific aplication which must run for each user from separate folder on Win 2012R2 RDS servers) with this command:
FOR /D %%G in (“ts*”) DO reg add “HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers” /v d:\%%G\AppName.exe /t REG_SZ /d “~ HIGHDPIAWARE 16BITCOLOR WINXPSP2 DisableNXShowUI” /f
I’m assuming this doesn’t work any more in Windows 10 because… I have some items set to run as admin and they are not listed. If I add something in either Current User or Local Machine it does not run as an admin
Anyone knows why i have in this key different values for same entries, when i launch regedit as admin?! DisableDWM seems to be working, when i launch regedit as admin and add string, path and value there manually. As some entries are not there, when i launch it as admin (i am on local account). Windows 10 2004 here.