SERVICES
EVENT 7045
EVENT 4697
IMAGEPATH
DetectionBlue TeamSOCOctober 12, 2026•9 min read

Detecting Windows Service Persistence: Events 7045 and 4697

A new service is a loud event that runs as SYSTEM at boot. Attackers still use them because most environments never alert on 7045.

Scroll

Creating a Windows service gives an attacker code execution as SYSTEM that starts before any user logs on. It is also how PsExec-style lateral movement, ransomware deployment and many backdoors execute. Service Control Manager logs every installation as System Event 7045, and the Security log adds Event 4697 where auditing is enabled. Both carry the service name and the exact ImagePath, which is the field to analyse.

Signals at a Glance

SignalWhereATT&CK
New service installed (7045 System, 4697 Security)Service Control Manager, Security logT1543.003
ImagePath contains cmd /c, powershell, %COMSPEC% or a UNC path7045 / 4697 ServiceFileNameT1569.002
ImagePath in Temp, AppData, ProgramData or Users\Public7045 / 4697T1543.003
Service start type changed to auto-start (7040)System logT1543.003
Direct write to Services\<name>\ImagePath without sc.exe or SCMSysmon 13T1112
New kernel driver service from an unsigned or unusual pathSysmon 6, 7045 ServiceTypeT1068

Installation Events and ImagePath

The Security log version, Event 4697, is parsed into discrete fields by most SIEM connectors, which makes the ImagePath easy to hunt. Random-looking service names, ImagePaths that wrap a shell, and services pointing at user-writable directories account for most true positives:

// KQL (Sentinel): suspicious service installs from Security 4697
SecurityEvent
| where EventID == 4697
| where ServiceFileName matches regex @"(?i)(\\Temp\\|\\AppData\\|\\ProgramData\\|\\Users\\Public\\|cmd(\.exe)?\s+/c|powershell|%COMSPEC%|\\\\[^\\]+\\)"
   or ServiceName matches regex @"^[A-Za-z0-9]{8,16}$"
| project TimeGenerated, Computer, SubjectUserName, ServiceName, ServiceFileName,
          ServiceType, ServiceStartType
| order by TimeGenerated desc
// tune/validate: the random-name clause is noisy; keep it only for hosts without management agents.

Event 4697 is not always enabled, so the System log version is the safer base. This Sigma rule covers 7045 and mirrors what most public rule sets look for:

title: Suspicious Service Installed
logsource:
  product: windows
  service: system
detection:
  selection:
    Provider_Name: 'Service Control Manager'
    EventID: 7045
  susp_path:
    ImagePath|contains:
      - '\Temp\'
      - '\AppData\'
      - '\ProgramData\'
      - '\Users\Public\'
      - '\\127.0.0.1\'
      - 'cmd.exe /c'
      - 'powershell'
  condition: selection and susp_path
level: high
# tune/validate: legitimate agents install from ProgramData; baseline before paging on it.

Context That Separates Persistence from Admin Work

Vetted sources

Reference the SigmaHQ service-installation rules, Elastic’s service-creation detections, Splunk ESCU content for T1543.003, MITRE CAR analytics and Atomic Red Team T1543.003 tests. Use Autoruns or osquery’s services table for inventory. Baseline your own environment, because monitoring, backup and EDR products install services regularly.

Build Detections That Fire

Mjolnir Security helps blue teams turn threat intelligence into high-fidelity detections across endpoint, network, identity and cloud telemetry.

Detection EngineeringManaged Detection & ResponseThreat HuntingIncident ResponsePurple Teaming
  • Detection Engineering We build and tune detections mapped to ATT&CK from your own telemetry.
  • Threat Hunting as a Service Hypothesis-driven hunts for the behaviours on this page.
  • 24/7 Incident Response Containment when a detection fires. Call +1 833 403 5875.
Written by: Mjolnir Threat Research (MTAC)  |  Published: October 12, 2026  |  Last reviewed: October 12, 2026