Windows Event ID 4697: A service was installed in the system
Security event 4697 records a new Windows service with its name, binary path, start type and account. Key for PsExec-style lateral movement and persistence.
Overview
- Event ID
- 4697
- Log / channel
- Security
- Provider
- Microsoft-Windows-Security-Auditing
- Category
- service
- Enabled by default
- No
- How to enable
- Advanced Audit Policy Configuration > System > Audit Security System Extension (Success). Not enabled in the default audit policy.
What event 4697 logs
Event 4697 is written when a service is registered with the Service Control Manager. It records the service name (ServiceName), the command it will run (ServiceFileName), how it starts (ServiceStartType), its type (ServiceType) and the account it runs as (ServiceAccount), together with the account that installed it (Subject*).
It is the Security-log twin of System event 7045, which is logged by the Service Control Manager on every system without any audit policy. 4697 needs the Security System Extension subcategory, but adds the installing account and logon session — useful to tie the install to a specific remote logon.
New services are a favorite for both persistence and remote execution: PsExec, Impacket smbexec/psexec, Cobalt Strike jump psexec and many ransomware operators create a service on the target to run their payload as SYSTEM. Driver installations (kernel services) also show up here.
Fields
Every field recorded in event 4697, with the values that matter for investigation.
SubjectUserNameAccount that installed the service. For remote installs this is the remote admin account; HOST$ means SYSTEM.
SubjectLogonIdLogon session of the installer; pivot to its 4624 (often a type 3 network logon) to find the source.
ServiceNameName of the new service. Random-looking or very short names are a red flag.
ServiceFileNameCommand line the service runs. Look for cmd.exe /c, powershell, paths under \Temp\, ADMIN$ / C:\Windows\ root, or encoded arguments.
ServiceTypeKind of service.
- 0x1
- Kernel driver.
- 0x2
- File system driver.
- 0x8
- Recognizer driver.
- 0x10
- Win32 service running in its own process.
- 0x20
- Win32 service sharing a process (svchost-hosted).
- 0x110
- Own-process service allowed to interact with the desktop.
- 0x120
- Shared-process service allowed to interact with the desktop.
ServiceStartTypeWhen the service starts.
- 0
- Boot — driver loaded by the boot loader.
- 1
- System — driver started during kernel initialization.
- 2
- Automatic — started at boot by the Service Control Manager.
- 3
- Manual (demand start).
- 4
- Disabled.
ServiceAccountAccount the service runs as, e.g. LocalSystem, NT AUTHORITY\LocalService or a domain account.
How to enable this event
Advanced Audit Policy Configuration > System > Audit Security System Extension (Success). Not enabled in the default audit policy.
System event 7045 covers the same installs by default and should be checked when 4697 is not audited.
Detection and investigation
Typically benign
- Software installs and updates (drivers, agents, browsers' update services).
- Management and remote support tools that install a temporary service on the target.
- Windows feature and role installation.
Worth investigating
- Remote execution via PsExec or Impacket: a new demand-start service with a random or tool-specific name, running a binary from
ADMIN$or acmd.exe /c/%COMSPEC%command line. - Persistence through an automatic-start service pointing to a payload in a user-writable folder.
- Loading a malicious or vulnerable kernel driver (ServiceType
0x1, start type 0–3) to disable security tools.
Investigation notes
- Review ServiceFileName first: anything outside
Program Files/System32or containing a shell, script host or encoded blob deserves attention. - Pivot on SubjectLogonId to the 4624 on the same host — a type 3 logon seconds before the install reveals the source IP of remote execution.
- Correlate with System 7045 and 7036 (service started/stopped) to see whether it ran and was removed.
- Look for 4688 children of
services.exeright after the install to see what the service executed.