Skip to content

AppCompatFlags Layers: RUNASADMIN and Compatibility Modes

How AppCompatFlags Layers stores compatibility modes and Run as administrator per executable, in NTUSER.DAT and SOFTWARE, and how to read it as evidence.

Published on 7 min read

TL;DR. Software\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers holds one string value per executable: the name is the full path, the data is a list of compatibility layers such as WIN7RTM, HIGHDPIAWARE or RUNASADMIN. Settings for one user live in that user's NTUSER.DAT (HKCU), settings for all users in the SOFTWARE hive (HKLM). File Explorer's Compatibility tab writes them with a leading ~ . A Layers value shows that someone asked Windows to start a program in a certain way; it does not show that the program ran, and only the key has a time. In an intrusion, RUNASADMIN on a tool in a user-writable folder is worth explaining. PCA Parser reads the Layers key from NTUSER.DAT and SOFTWARE hives and joins it with the other PCA traces per executable.

Where it is

HiveKeyScope
NTUSER.DATSoftware\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\LayersThe user whose hive it is
SOFTWAREMicrosoft\Windows NT\CurrentVersion\AppCompatFlags\LayersEvery user of the machine

RegRipper's appcompatflags plugin also checks the Wow6432Node copies of these paths. The key may not exist at all: it is created when the first value is written.

Who writes where, according to Microsoft's Vista-era PCA documentation and practice:

  • The Compatibility tab of an executable's properties writes to HKCU. Its Change settings for all users button writes to HKLM, which needs administrator rights.
  • The Program Compatibility Assistant writes the fixes it applies to HKLM, except ELEVATECREATEPROCESS, which it applies automatically and writes to HKCU. Its Windows 8 scenarios page lists RUNASADMIN among those fixes, applied with the user's agreement to an installer that failed without elevation or to a legacy Control Panel applet.
  • Anyone with access to the key can write a value directly, with reg add, PowerShell or an installer. A user can always write to their own HKCU.

Value format

Name : C:\ProgramData\Intel\m64.exe
Type : REG_SZ
Data : ~ RUNASADMIN
  • The name is the full path of the executable.
  • The data is a space-separated list of layers. When the Compatibility tab writes it, the list starts with ~ . The Broken Event write-up observed that Explorer sets the tilde and the value works without it; Microsoft does not document it. Scripts and older write-ups often set values without it, so a tilde points to the tab and a missing one to some other writer, but neither is proof.
  • Clearing every box on the Compatibility tab deletes the value.
  • Forum reports describe value names that are not paths but start with SIGN.MEDIA=, followed by a hex value and a relative file name, for programs on removable media or network shares. Microsoft does not document that format.

Common layers

Microsoft defines the modes PCA itself applies in its Program Compatibility Assistant scenarios page. The Compatibility tab adds a few more.

LayerMeaningSource
RUNASADMIN"Always prompts the user to run the app with administrative privileges"Microsoft
RUNASHIGHESTPrompts to run with the highest privilege the user hasMicrosoft
ELEVATECREATEPROCESSChild processes of the program run elevated, with a UAC promptMicrosoft
RUNASINVOKERRuns without elevation, with the rights of the process that started itObserved (Broken Event)
WINXPSP3, VISTASP2, WIN7RTM, WIN8RTMEmulate an older Windows versionModes described by Microsoft; strings observed
HIGHDPIAWARE, DPIUNAWARE, GDIDPISCALINGDisplay scaling behaviourHIGHDPIAWARE described by Microsoft; others observed
256COLOR, 16BITCOLOR, 640X480Reduced colour or resolutionObserved
DISABLEDXMAXIMIZEDWINDOWEDMODETurns off full-screen optimizationsObserved

What a value proves

It showsIt does not show
That a layer was requested for this exact pathThat the program ever ran
For one user (NTUSER.DAT) or all users (SOFTWARE)When this value was written, if other values changed later
That the path existed as a string someone typed or browsed toThat the file is still there

Registry values have no timestamp of their own. The key's LastWrite time, in UTC, dates the most recent change to any value in the key. On a long-used machine with many values, it says little about one value. In a profile created during an intrusion, with one value, it is the time that value was written.

RUNASADMIN as evidence

RUNASADMIN does not grant privileges. With User Account Control on, it makes Windows ask for elevation every time the program starts: with default UAC settings, a consent prompt for an administrator and a credentials prompt for a standard user. So a RUNASADMIN value on an attacker's tool tells you three things:

  1. Someone expected the tool to need administrator rights.
  2. They expected to be at the screen to answer a UAC prompt, which fits an interactive or RDP session rather than a remote shell.
  3. They set it on a path they planned to run again.

The usual sequence is: the program is started, fails or misbehaves without elevation, the user ticks Run this program as an administrator, and starts it again. A PcaGeneralDb abnormal exit with code 0xc000042c (STATUS_ELEVATION_REQUIRED) on the same path, just before the key's LastWrite time, would fit that story; check for one.

On FIN-WKS-07, the fictional workstation used on this site, the rogue account svc_backup started C:\ProgramData\Intel\m64.exe from File Explorer at 10:09:44 UTC; PcaAppLaunchDic.txt holds that time. Its NTUSER.DAT has a Layers key with a single value, C:\ProgramData\Intel\m64.exe = ~ RUNASADMIN, and the key's LastWrite time is 10:10:05. The account was created at 09:57:41, so its hive dates from the intrusion and the key holds only this value: 10:10:05 is when the value was written, 21 seconds after the GUI launch, and the tilde points to the Compatibility tab. Whether m64.exe then ran elevated is a question for Prefetch run times and event logs. The PCA launch line keeps only the last launch it recorded, and no public research says whether an elevated start updates it. The full case is in investigating program execution with PCA traces.

Other things to look for

  • RUNASINVOKER on an installer or admin tool. It lets a program that asks for elevation start without a prompt, with the user's own rights. Rarely set by ordinary users.
  • Layers on paths in Downloads, %TEMP%, C:\Users\Public or C:\ProgramData. Legitimate old software lives under Program Files.
  • Values in HKLM for user-writable paths. Someone with administrator rights chose to apply a layer for every user.
  • Values for paths that no longer exist. Values outlive the files they name.
  • No value at all. Layers can also be requested for a single process through the __COMPAT_LAYER environment variable, for example __COMPAT_LAYER=RunAsInvoker, which writes nothing to the registry.

Layers and the other PCA keys

Layers sits next to the Compatibility Assistant Store under AppCompatFlags, but they record different things. Store lists the programs PCA dealt with for a user. Layers lists the programs someone configured. A path in Layers and not in Store, or the other way round, is normal. A path in both, and in PcaAppLaunchDic.txt, gives you a user, a configuration change and a launch time.

FAQ

What does ~ RUNASADMIN mean in the Layers key?

RUNASADMIN is the layer behind the Run this program as an administrator box on the Compatibility tab: the program always asks for elevation. The tilde and space are written by File Explorer when the setting comes from that tab. Microsoft does not document the tilde, and the setting works without it.

Does a Layers value prove that the program ran?

No. It proves that someone or something asked Windows to start that path with a given layer. It is often set after a first run, but it can be written for a program that never ran. Take execution from Prefetch, BAM, the PCA files or event logs.

When was a Layers value set?

Registry values have no time of their own. The Layers key's LastWrite time dates the last change to the key, which is the value's time only if nothing else in the key changed afterwards.

Is the Layers key in NTUSER.DAT or SOFTWARE?

Both. Settings for one user go to HKCU, in that user's NTUSER.DAT. Settings for all users, made with Change settings for all users on the Compatibility tab or applied by PCA itself, go to HKLM, in the SOFTWARE hive.

Frequently asked questions

What does ~ RUNASADMIN mean in the Layers key?

RUNASADMIN is the layer behind the Run this program as an administrator box on the Compatibility tab: the program always asks for elevation. The tilde and space are written by File Explorer when the setting comes from that tab. Microsoft does not document the tilde, and the setting works without it.

Does a Layers value prove that the program ran?

No. It proves that someone or something asked Windows to start that path with a given layer. It is often set after a first run, but it can be written for a program that never ran. Take execution from Prefetch, BAM, the PCA files or event logs.

When was a Layers value set?

Registry values have no time of their own. The Layers key's LastWrite time dates the last change to the key, which is the value's time only if nothing else in the key changed afterwards.

Is the Layers key in NTUSER.DAT or SOFTWARE?

Both. Settings for one user go to HKCU, in that user's NTUSER.DAT. Settings for all users, made with Change settings for all users on the Compatibility tab or applied by PCA itself, go to HKLM, in the SOFTWARE hive.

Related articles

How to collect C:\Windows\appcompat\pca and the AppCompatFlags keys in NTUSER.DAT and SOFTWARE: locked hives, KAPE, Velociraptor and your own traces.
The per-user Compatibility Assistant keys: Persisted on Windows Vista and 7, Store on Windows 8 to 11, what their values show and what is undocumented.
What PcaAppLaunchDic.txt records on Windows 11 22H2 and later: one line per program launched from the GUI, its last launch time in UTC, and its limits.