Skip to content

Startup Folder: Programs That Run at Windows Logon

How the per-user and all-users Startup folders run shortcuts and scripts at every Windows logon, how attackers abuse them, and how to find and remove the items.

MITRE ATT&CK
T1547.001
Tactics
Persistence, Privilege escalation
Runs
At logon
Set up by
Users and administrators
Locations
  • %APPDATA%\Microsoft\Windows\Start Menu\Programs\Startup
  • C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Startup
  • HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders
  • HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders
  • HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\StartupApproved\StartupFolder

How it works

At logon, Explorer opens every item in two folders: the user's own Startup folder and the all-users (common) Startup folder. It treats each item as if the user had double-clicked it. A shortcut (.lnk) starts its target with the shortcut's arguments, working folder and window state. A program starts directly. Any other file opens with the program its extension is associated with: .bat and .cmd in cmd.exe, .vbs and .js in wscript.exe, .hta in mshta.exe, and an Internet shortcut (.url) with whatever handles its address. A .ps1 file opens in Notepad by default, which is why attackers point a shortcut at powershell.exe instead of dropping the script itself.

Everything starts in the session of the user who logged on, as that user, with explorer.exe as parent. The common folder applies to every user, but it gives no more privilege than the per-user one: it needs administrator rights to write, and it runs code in every account's session.

Explorer finds both folders through the registry. The Startup value in HKCU\...\Explorer\User Shell Folders and the Common Startup value in the HKLM key of the same name hold the paths, as REG_EXPAND_SZ; the Shell Folders keys next to them keep an older, expanded copy. ATT&CK lists all four keys, because changing a value moves the folder Explorer runs.

Since Windows 8, Task Manager's Startup tab can switch an item off without deleting it. The choice is recorded in ...\Explorer\StartupApproved\StartupFolder, a binary value named after the file. The Run keys page describes the format.

Where it lives

LocationDefault pathWho can write it
Per-user Startup folder (shell:startup)C:\Users\<name>\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\StartupThe user
All-users Startup folder (shell:common startup)C:\ProgramData\Microsoft\Windows\Start Menu\Programs\StartupAdministrators, SYSTEM
HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders, value Startup%USERPROFILE%\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\StartupThe user
HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders, value Common Startup%ProgramData%\Microsoft\Windows\Start Menu\Programs\StartupAdministrators, SYSTEM
...\Explorer\StartupApproved\StartupFolder (in HKCU and HKLM)Absent until an item is switched offExplorer

On a stock Windows 10 or 11 system, both folders hold only a hidden desktop.ini. Software adds shortcuts during installation; anything else deserves a reason. With roaming profiles or folder redirection, the per-user folder can sit on a file server.

How attackers use it

The Startup folder needs no registry write at all, only a file copy, so droppers and scripts use it often. Three forms are common.

A shortcut to the payload, often minimised and with an icon borrowed from a real program. PowerShell can make one without any tool:

$s = (New-Object -ComObject WScript.Shell).CreateShortcut("$env:APPDATA\Microsoft\Windows\Start Menu\Programs\Startup\OneDrive Sync.lnk")
$s.TargetPath = 'C:\Users\Public\Libraries\sync.exe'; $s.WindowStyle = 7; $s.Save()

A script dropped in the folder directly, which runs through its file association:

copy update.vbs "%APPDATA%\Microsoft\Windows\Start Menu\Programs\Startup\"

A shortcut whose target is a built-in program and whose arguments carry the attack: powershell.exe -w hidden -enc …, mshta.exe with a URL, rundll32.exe with a DLL in a user folder, cmd.exe /c start with a script. The shortcut's file name and icon say "Teams" or "OneDrive"; only the arguments say otherwise.

Less common variants:

  • An Internet shortcut (.url) whose URL= line is a file: path or a UNC share, so a program runs instead of a web page.
  • Redirecting the folder: pointing User Shell Folders\Startup at a folder the attacker controls. The real folder stays clean and a quick look at it finds nothing.
  • With administrator rights, the common folder, which reaches every user who logs on.

How to check a host

On a live machine:

Get-ChildItem -Force "$env:ProgramData\Microsoft\Windows\Start Menu\Programs\Startup"
Get-ChildItem -Force 'C:\Users\*\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup'
$l = (New-Object -ComObject WScript.Shell).CreateShortcut('C:\Users\alice\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup\OneDrive Sync.lnk')
$l.TargetPath; $l.Arguments; $l.WindowStyle
reg query "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" /v Startup
reg query "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" /v "Common Startup"
reg query "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\StartupApproved\StartupFolder"

CreateShortcut on an existing .lnk reads it without changing it. Autoruns (autorunsc.exe -accepteula -a l -s -h -c *) lists the items with the logon entries, resolves shortcuts and checks signatures.

Offline, collect both folders with their file times, and the NTUSER.DAT of each user for the shell folder values. A shortcut carries more than its target: the target's own timestamps and size when the link was made, the volume serial number, and often the NetBIOS name and MAC address of the machine that created it. LECmd (Eric Zimmerman) prints all of it. A shortcut made on a machine that is not this one, or whose target timestamps predate the intrusion by years, tells you where it came from. Sysmon event 11 (file created) on a path containing \Start Menu\Programs\Startup\ catches new items as they appear.

What stands out: anything that is not a shortcut, a shortcut to an interpreter or a built-in program with arguments, a target in a temporary, public or profile folder, a minimised window state, a file newer than the software it claims to belong to, and a Startup or Common Startup value that is not the default.

What Windows Persistence flags

The tool reads every file in the collected Startup folders, C:\ProgramData\...\Startup and each C:\Users\<name>\AppData\Roaming\...\Startup, and skips desktop.ini. Items in the all-users folder belong to no user and count as machine-wide. Task Manager's switch is applied from StartupApproved\StartupFolder, read in the user's NTUSER.DAT for that user's items and in the SOFTWARE hive for the all-users folder: a matching value marks the item enabled or disabled, with the date under "Switched off in Task Manager".

  • Shortcuts: the command is the target (from the link's LinkInfo, its environment-variable block, its item ID list or its relative path) followed by the arguments. The entry shows the working folder, the comment, the icon and the target's creation time. Shortcut starts minimised (low) when the window state is minimised.
  • Internet shortcuts: Internet shortcut in a Startup folder, high when the address is a file: path or a UNC share, medium otherwise.
  • Any other file: Program or script in a Startup folder, medium for programs and scripts (.exe, .scr, .dll, .bat, .cmd, .vbs, .js, .ps1, .hta, .jar, .py and similar), low for other files. For .bat, .cmd, .vbs, .js, .ps1, .wsf and .hta, the command-line rules also run on the first 64 KB of the file's text.

The command-line rules run on every shortcut and Internet shortcut: Downloads and runs code, Encoded PowerShell command, Runs with a hidden window, Bypasses the PowerShell execution policy, Runs from a temporary or public folder, Runs from a network share, Windows program used to run outside code, Script run by the Windows script host, Windows program name in the wrong place, Name one letter away from a Windows program, Machine-made name and the others. System-wide autostart from a writable folder applies to items in the all-users folder only.

Across mechanisms: Written date when the file was modified in the 7 days before the newest time collected from that host, Inside a Defender exclusion (exclusion), and program also runs from mechanisms.

With Hide Windows entries on, a shortcut whose target sits in Windows' folders and raises no flag is hidden.

Limits: the tool reads the two default folders only. It does not read the User Shell Folders or Shell Folders values, so a redirected Startup folder is not followed; check those values by hand. It reads the shortcut, not the program behind it, and checks no signatures.

Cleaning up

  1. Preserve the item and its times before touching it: copy the folder with robocopy <folder> <evidence> /COPY:DAT /DCOPY:T, and hash the shortcut's target with Get-FileHash. Keep the .lnk: its metadata is evidence.
  2. Stop the running process, then delete the item: Remove-Item -LiteralPath 'C:\Users\alice\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup\OneDrive Sync.lnk'. Then delete the target program or script.
  3. If a shell folder value was changed, restore the default and inspect the folder it pointed to: Set-ItemProperty -Path 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders' -Name Startup -Value '%USERPROFILE%\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup' -Type ExpandString.
  4. Leave desktop.ini and shortcuts installed by known software in place. Switching an item off in Task Manager is not removal.
  5. Check every profile and the other logon mechanisms (Run keys, logon scripts, scheduled tasks) for the same program, then rotate the user's passwords and sessions.

See also

On Windows Forensics

The artifacts behind this technique, in the Windows Forensics reference: