OmniGuard nsite.tech
← All articles
· 3 min read

Where Windows lets programs start themselves

Persistence is the step that turns a one-off execution into a permanent presence. There are more places to hide than the Startup folder, and most of them are worth auditing.

persistenceforensicsautoruns

Getting code to run once on a machine is the easy part. Getting it to run again after a reboot is what turns an incident into an infestation.

Windows offers a generous number of places to arrange that. Knowing them makes the difference between cleaning a machine and thinking you cleaned it.

The obvious ones

Run and RunOnce keys — still the most common, still worth checking first:

foreach ($h in 'HKLM','HKCU') {
  foreach ($k in 'Run','RunOnce') {
    Get-ItemProperty "${h}:\SOFTWARE\Microsoft\Windows\CurrentVersion\$k" -EA SilentlyContinue
  }
}

Startup folders, per-user and machine-wide:

Get-ChildItem "$env:APPDATA\Microsoft\Windows\Start Menu\Programs\Startup"
Get-ChildItem "$env:ProgramData\Microsoft\Windows\Start Menu\Programs\Startup"

Scheduled tasks — the most popular modern option, because they support triggers far richer than "at logon":

Get-ScheduledTask | Where-Object State -ne 'Disabled' |
  Select-Object TaskPath, TaskName, @{n='Action';e={ ($_.Actions.Execute -join '; ') }}

Services set to start automatically, particularly ones whose binary lives somewhere unusual:

Get-CimInstance Win32_Service | Where-Object { $_.StartMode -eq 'Auto' } |
  Select-Object Name, PathName | Where-Object PathName -notmatch '^"?C:\\Windows'

The less obvious ones

WMI event subscriptions are the sophisticated choice: fileless, survive reboots, and invisible to anyone looking only at Run keys and tasks.

Get-CimInstance -Namespace root\subscription -ClassName __EventFilter
Get-CimInstance -Namespace root\subscription -ClassName CommandLineEventConsumer
Get-CimInstance -Namespace root\subscription -ClassName __FilterToConsumerBinding

On a normal workstation these are nearly empty. Anything unexpected here deserves real scrutiny. There is an ASR rule specifically for this technique, and it is worth enabling.

Winlogon keys (Shell and Userinit under HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon) should point at explorer.exe and userinit.exe and nothing else.

Image File Execution Options debuggers — a value named Debugger under a program's IFEO key launches that program instead of the real one.

Print monitors, LSA packages and AppInit DLLs round out the list. All legacy, all still functional.

Triage: what makes an entry suspicious

The list will be long, and most of it legitimate. Useful discriminators, roughly in order:

  • Is it signed, and by whom? Get-AuthenticodeSignature on the target. Unsigned in a user-writable directory is the strongest single signal.
  • Where does the binary live? Program Files is normal. AppData, ProgramData, %TEMP% and Public deserve a second look — though plenty of legitimate per-user applications live in AppData, so this is a prompt, not a verdict.
  • When did it appear? Compare its creation time against when the problem started.
  • Does the name impersonate something? svch0st.exe, or a legitimate name in the wrong directory.

Resist the shortcut of matching on names. A hardcoded list of "known good" program names is how scanners end up trusting anything that renames itself — and how they flag legitimate software that is not on the list. Check the signature and the path instead.

Disable, do not delete

When you find something you cannot account for, disable it rather than removing it, and record what you changed. A disabled scheduled task can be re-enabled in seconds if it turns out to be your backup software; a deleted one has to be reconstructed.

And if something reappears after you remove it, stop and find what is re-creating it. Deleting it again is not a fix — there is a second mechanism you have not found yet, and that one is the actual problem.

OmniGuard puts this on autopilot — threats, network, Bluetooth and hardening in one console.
Download OmniGuard