Is there a way to set the compatibility with XP option (right click/properties/compatibility ... that one, yes :) to an executable from the command line?

Or better yet, is there a way to set compatibility to a whole directory (executables in the directory), so that every executable that gets compiled/build already has that "flag" on it?

  • 1
    @CodyGray - Because I'm using an old compiler IDE (from Win95); changing to a new one would induce some costs we're not prepared for right now. If I build it and start it from the IDE, the whole thing crashes. If I put compability and start it from the explorer, it works. Which is good enough for me. Only I don't like putting compatibility flag every time after the build. Therefore the question ... :)
    – Rook
    Jan 13, 2012 at 2:33
  • 1
    @CodyGray - Well, I could give you the whole story but I doubt it would fit in the commments box here (or three of them), so I'll just leave the question open for a while longer ...
    – Rook
    Jan 13, 2012 at 9:11
  • 1
    Ah, I knew I remembered reading that in an article. I finally found it and posted an answer for posterity. :-) Feel free to ignore my nagging, but I seriously doubt you'll find an alternative approach. Jan 13, 2012 at 9:36

3 Answers 3


I don't know a tools that allows to set or change the application compatibility flags.

However the application compatibily flags are stored in the registry (user or system part):

HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers
HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers

Therefore you can use the standard command line registry editor for creating the required entry:

reg.exe Add "HKLM\Software\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers" /v "C:\Program Files\MyApp\Test.exe" /d "WINXPSP3"

For more details on the available flags see the blog post Running an Application as Administrator or in Compatibility Mode.

  • 1
    Hmm, this just might(!) work ... that third line "reg.exe ..." ... so if I set it for every exe I have in some directory, it will "stay attached" to that executable even if it is rebuild?
    – Rook
    Jan 17, 2012 at 14:44
  • 2
    The normal behavior of right-click > Properties > Compatibility is to set the keys under HKCU, unless the "Change settings for all users" button is pressed. Then it is set under HKLM for all users, and can't be changed via the dialog.
    – Mike Brown
    Jan 22, 2013 at 7:35

In a batch file use:


before the .exe call


  • 4
    +1 Starting an .exe through a .bat seems the least invasive solution
    – Wolf
    Nov 20, 2014 at 10:25

Robert's answer was spot-on. To expand on it a bit, and answer the OP's question about setting the mode en masse...

If you have a folder full of .exe files to process, you can do this:

for %x in ("*.exe") do reg.exe Add "HKCU\Software\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers" /v "%~fx" /d "WINXPSP3"

This example uses HKCU instead of HKLM; be sure to pick the one you really want.

To remove the settings, with a confirmation prompt for each one:

for %x in ("*.exe") do reg.exe Delete "HKCU\Software\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers" /v "%~fx"

Add /f to the end if you don't want to be prompted for confirmation.

(If you vote this answer up, please vote up Robert's as well!)

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .