Skip to content

Persistence

Run keys and Startup folders

Run keys and Startup folders cheat sheet: Run, RunOnce, Wow6432Node and Policies paths, StartupApproved enabled/disabled bytes, timestamps and pitfalls.

Location
NTUSER.DAT\Software\Microsoft\Windows\CurrentVersion\Run
Proves
A program was configured to start at logon, for one user or all users
Timestamps
Run key LastWrite and StartupApproved disable time as FILETIME, UTC; Startup folder files $SI/$FN times, UTC
Retention
Entries persist until removed, with no default event; RunOnce values deleted when they run; older values in hive logs and VSS
Access
NTUSER.DAT and SOFTWARE locked live: collect via raw NTFS or VSS, or reg save; Startup folders copy directly
Evidence of
Persistence
Type
Registry
Windows
XPVista / 78 / 8.11011
KAPE target
RegistryHivesUserRegistryHivesSystemStartupFolders
Velociraptor
Windows.Triage.Targets:RegistryHivesUserRegistryHivesSystemStartupFolders

What it is

Run keys and Startup folders are the oldest and most common autostart locations in Windows. Every command line stored under a Run key, and every file dropped in a Startup folder, is launched when a user logs on. No administrative rights are needed for the per-user locations, which makes them a favourite first persistence mechanism for commodity malware and a quick win when triaging a host.

On Windows 8 and later, the StartupApproved keys record whether each entry is enabled or disabled, as set in Task Manager's Startup tab (and in Settings on Windows 10/11).

Location

ScopeLocationNotes
Current userNTUSER.DAT: Software\Microsoft\Windows\CurrentVersion\Run and \RunOnceRuns at that user's logon
All usersSOFTWARE: Microsoft\Windows\CurrentVersion\Run and \RunOnceHKLM RunOnce only runs when an administrator logs on
32-bit entries on 64-bit WindowsSOFTWARE: WOW6432Node\Microsoft\Windows\CurrentVersion\Run and \RunOnceWritten by 32-bit installers
Policy-basedMicrosoft\Windows\CurrentVersion\Policies\Explorer\Run (SOFTWARE and NTUSER.DAT)Normally set by Group Policy
Enabled/disabled state (8+)Microsoft\Windows\CurrentVersion\Explorer\StartupApproved\Run, \Run32, \StartupFolder (SOFTWARE and NTUSER.DAT)One value per entry name
User Startup folder (Vista+)C:\Users\<user>\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup
All-users Startup folder (Vista+)C:\ProgramData\Microsoft\Windows\Start Menu\Programs\StartUp
Startup folders (XP)C:\Documents and Settings\<user>\Start Menu\Programs\Startup and ...\All Users\Start Menu\Programs\Startup

The folder locations themselves come from Shell Folders / User Shell Folders under Software\Microsoft\Windows\CurrentVersion\Explorer (values Startup and Common Startup). Redirecting them is a persistence trick in its own right.

What it proves

  • A program was set to start at logon, with its full command line (registry) or as a file or shortcut in a Startup folder.
  • Scope: an NTUSER.DAT entry belongs to that user; a SOFTWARE entry applies to every user.
  • Enabled or disabled: StartupApproved shows whether Windows will actually launch the entry.
  • It does not prove the program ran. Confirm with Prefetch, BAM or process events.

Key fields

FieldMeaning
Value name (Run / RunOnce)Arbitrary label, often imitating a vendor name
Value dataCommand line (up to 260 characters), including arguments
! prefix on a RunOnce value nameDelete the value only after the command has run
* prefix on a RunOnce value nameRun even in Safe Mode
StartupApproved data, first byte0x02 enabled, 0x03 disabled
StartupApproved data, bytes 4–11FILETIME when the entry was disabled (zero when enabled)
Startup folder file.lnk, .bat, .vbs, .exe, .url or any launchable file

Timestamps

TimestampSet whenFormatPitfalls
Run key LastWriteAny value under the key is added, changed or deletedFILETIME, UTCDescribes the key, not a specific value; legitimate installers update it often
StartupApproved disable timeEntry disabled in Task Manager or SettingsFILETIME, UTC, inside the value dataZeroed when the entry is re-enabled
Startup folder file $SI / $FN timesFile created, modifiedNTFS, UTC$SI can be timestomped; compare with $FN in the $MFT
LNK internal timesTarget file times at shortcut creationFILETIME, UTCDescribe the target, not the shortcut; see LNK files

Retention and clearing

  • Run entries stay until removed. Removal leaves no event by default; look for older values in hive transaction logs, in volume shadow copies and in unallocated hive space.
  • RunOnce values are deleted by Windows just before (or, with !, just after) they run, so a one-shot payload may leave only the key LastWrite and execution artifacts.
  • Deleting a value from Run does not remove its StartupApproved entry; an orphan StartupApproved value can reveal a removed Run entry.
  • A decoy trick: an entry added to Run but marked disabled in StartupApproved looks like persistence yet never runs. Always check both.

Collection

  • KAPE target: RegistryHivesUser (NTUSER.DAT), RegistryHivesSystem (SOFTWARE) and StartupFolders.
  • Velociraptor (Windows.Triage.Targets): RegistryHivesUser, RegistryHivesSystem, StartupFolders. Live: Windows.Sys.StartupItems combines Run keys, StartupApproved and Startup folders.
  • Built-in: the loaded NTUSER.DAT is locked; use reg save for the logged-on user or collect it from a shadow copy.
reg query HKCU\Software\Microsoft\Windows\CurrentVersion\Run
reg query HKLM\Software\Microsoft\Windows\CurrentVersion\Run
reg query HKLM\Software\WOW6432Node\Microsoft\Windows\CurrentVersion\Run
reg query HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\StartupApproved /s
dir /a /t:c "%APPDATA%\Microsoft\Windows\Start Menu\Programs\Startup" "%ProgramData%\Microsoft\Windows\Start Menu\Programs\StartUp"

Parsing tools

  • Registry Explorer / RECmd (Eric Zimmerman): browse keys and export them with the community batch files.
  • RegRipper: run plugin (SOFTWARE and NTUSER.DAT, including StartupApproved paths) and runonceex.
  • Autoruns (Sysinternals, free): Logon tab lists Run keys and Startup folders, live or against an offline Windows directory.
  • Velociraptor: Windows.Sys.StartupItems.
  • LECmd (Eric Zimmerman): parses .lnk files found in Startup folders.
  • Plaso: windows_run registry plugin.

Investigation tips

  • Flag command lines pointing to \AppData\, \Temp\, \Users\Public\, or using powershell, mshta, rundll32, regsvr32, wscript or encoded arguments.
  • Parse every user's NTUSER.DAT, including service and old accounts; persistence is often placed in a profile that is rarely used.
  • Check StartupApproved for each Run value: a disabled entry did not run at the latest logons, and its FILETIME tells you when it was disabled.
  • For Startup folder shortcuts, resolve the target and arguments of the .lnk and check the target's existence in the $MFT.
  • Correlate the Run key LastWrite with Prefetch and the user's logon times to confirm the payload started.
  • Continue with less common autostarts: Winlogon and IFEO, services and scheduled tasks.

Related artifacts

Glossary terms

All artifacts on one page: cheat sheet