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
Tools
Compare all toolsWhat 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
| Scope | Location | Notes |
|---|---|---|
| Current user | NTUSER.DAT: Software\Microsoft\Windows\CurrentVersion\Run and \RunOnce | Runs at that user's logon |
| All users | SOFTWARE: Microsoft\Windows\CurrentVersion\Run and \RunOnce | HKLM RunOnce only runs when an administrator logs on |
| 32-bit entries on 64-bit Windows | SOFTWARE: WOW6432Node\Microsoft\Windows\CurrentVersion\Run and \RunOnce | Written by 32-bit installers |
| Policy-based | Microsoft\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
| Field | Meaning |
|---|---|
| Value name (Run / RunOnce) | Arbitrary label, often imitating a vendor name |
| Value data | Command line (up to 260 characters), including arguments |
! prefix on a RunOnce value name | Delete the value only after the command has run |
* prefix on a RunOnce value name | Run even in Safe Mode |
| StartupApproved data, first byte | 0x02 enabled, 0x03 disabled |
| StartupApproved data, bytes 4–11 | FILETIME when the entry was disabled (zero when enabled) |
| Startup folder file | .lnk, .bat, .vbs, .exe, .url or any launchable file |
Timestamps
| Timestamp | Set when | Format | Pitfalls |
|---|---|---|---|
| Run key LastWrite | Any value under the key is added, changed or deleted | FILETIME, UTC | Describes the key, not a specific value; legitimate installers update it often |
| StartupApproved disable time | Entry disabled in Task Manager or Settings | FILETIME, UTC, inside the value data | Zeroed when the entry is re-enabled |
| Startup folder file $SI / $FN times | File created, modified | NTFS, UTC | $SI can be timestomped; compare with $FN in the $MFT |
| LNK internal times | Target file times at shortcut creation | FILETIME, UTC | Describe 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.
RunOncevalues 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
Rundoes not remove its StartupApproved entry; an orphan StartupApproved value can reveal a removed Run entry. - A decoy trick: an entry added to
Runbut marked disabled in StartupApproved looks like persistence yet never runs. Always check both.
Collection
- KAPE target:
RegistryHivesUser(NTUSER.DAT),RegistryHivesSystem(SOFTWARE) andStartupFolders. - Velociraptor (
Windows.Triage.Targets):RegistryHivesUser,RegistryHivesSystem,StartupFolders. Live:Windows.Sys.StartupItemscombines Run keys, StartupApproved and Startup folders. - Built-in: the loaded NTUSER.DAT is locked; use
reg savefor 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:
runplugin (SOFTWARE and NTUSER.DAT, including StartupApproved paths) andrunonceex. - 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
.lnkfiles found in Startup folders. - Plaso:
windows_runregistry plugin.
Investigation tips
- Flag command lines pointing to
\AppData\,\Temp\,\Users\Public\, or usingpowershell,mshta,rundll32,regsvr32,wscriptor 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
.lnkand 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
- Windows ServicesWindows services cheat sheet: Services key values (ImagePath, Start, Type, ServiceDll), 7045 and 4697 install events, PsExec traces and pitfalls.
- Scheduled TasksScheduled tasks cheat sheet: task XML and .job files, TaskCache registry keys, DynamicInfo times, hidden tasks, TaskScheduler and 4698 events.
- IFEO and Winlogon persistenceIFEO and Winlogon cheat sheet: Debugger hijacks, GlobalFlag and SilentProcessExit, sticky keys backdoors, Userinit/Shell, Notify and AppInit_DLLs.
- LNK shortcut filesLNK cheat sheet: Recent folder shortcuts, first and last open times, embedded target timestamps, volume serial, network share and TrackerDataBlock MAC.
- Registry hivesRegistry hives cheat sheet: SYSTEM, SOFTWARE, SAM, SECURITY, NTUSER.DAT, UsrClass.dat, transaction logs, RegBack, LastWrite times and collection.
- Prefetch Files (.pf)Windows Prefetch cheat sheet: .pf location per version, run count, the last eight run times, referenced files, retention limits and how to parse.
- Group Policy artifactsGroup Policy cheat sheet: SYSVOL policies, Registry.pol, GPP passwords, client-side history and event logs, and how attackers abuse GPO for mass deployment.
Glossary terms
- PersistenceMechanisms that let malware or an attacker survive reboots and logoffs, such as Run keys, services, scheduled tasks or WMI subscriptions.
- NTUSER.DATThe per-user registry hive stored in each Windows profile and loaded as HKEY_CURRENT_USER, rich in user activity and persistence traces.
- Registry key LastWrite timeThe single FILETIME stored in every registry key that records when the key or one of its values was last changed, in UTC.
- FILETIMEThe 64-bit Windows timestamp format counting 100-nanosecond intervals since 1 January 1601 UTC, used by NTFS, the registry and many artifacts.