Event ID 4697: A service was installed in the system
Event 4697 logs the installation of new Windows services, a common technique for persistence, privilege escalation, and malware execution. Services run with SYSTEM privileges and survive reboots, making them attractive to attackers. Monitor this event to detect malicious service installation.
- Channel
- Security
- Logged by default
- No
- Written on
- Target host
- Volume
- Low
- Audit subcategory
- Security System Extension
- Needs a SACL
- No
To have this event
- Enable Security System Extension:
auditpol /set /subcategory:"Security System Extension" /success:enable /failure:enable
Key fields
Exact XML field names, as they appear in <Data Name="…"> and in SIEM field extractions.
| Field | What it tells you |
|---|---|
| SubjectUserName | Account that installed the service |
| SubjectDomainName | Domain of the account |
| SubjectLogonId | Logon ID for correlation |
| ServiceName | Name of the installed service |
| ServiceFileName | Full path to the service executable |
| ServiceType | Service type (0x1=kernel driver, 0x2=file system driver, 0x10=own process, 0x20=share process) |
| ServiceStartType | Start type (0=boot, 1=system, 2=auto, 3=manual, 4=disabled) |
| ServiceAccount | Account used to run the service |
In an investigation
Event 4697 is generated whenever a new service is installed on a Windows system, recording the service name, executable path, service type, start mode, and the account that installed it. Windows services are powerful execution mechanisms that typically run with LocalSystem privileges, start automatically at boot time, and operate independently of user logons, making them highly valuable for attackers seeking persistent access. Malware families ranging from ransomware to banking trojans commonly install themselves as services to ensure execution persistence across reboots and to achieve elevated privileges. The event captures the complete service configuration including the executable path, which often reveals suspicious indicators such as binaries located in temporary directories, user-writable folders, or paths with random alphanumeric names. Service names themselves can be indicators, with attackers sometimes using names that mimic legitimate Windows services (e.g., 'WindowsUpdate' vs 'Windows Update') or generic names that blend into service lists. Remote service installation via PsExec or Service Control Manager remoting is a common lateral movement technique, where attackers install and start services on remote systems to execute payloads. Security analysts should baseline legitimate service installations in their environment, which outside of software deployments and patches should be relatively rare events. Any service installation outside maintenance windows, especially services configured to run non-standard executables or services installed via remote connections, warrants immediate investigation.
What it can reveal
- Services running executables from %TEMP%, %APPDATA%, or user directories are highly suspicious
- Services with SYSTEM privileges but obfuscated or random names indicate malware
- Remote service installation (via SMB or RPC) is a primary lateral movement technique
- Services that execute script interpreters (powershell.exe, cmd.exe) with parameters suggest malicious activity
- Immediate service start after installation with no reboot required is an attacker preference for fast execution
How to detect with it
Alert on all service installations and require them to be correlated with approved change management tickets or software deployment activities. Flag services installed from unexpected paths, particularly user-writable directories and network shares. Monitor for services installed via remote connections (check source IP in related 4624 logon events). Create alerts for services with names that nearly match legitimate Windows services but have subtle differences. Track services installed with AUTO_START that launch immediately, as these provide instant execution for attackers. Correlate service installation with process creation (4688) to see what executable the service runs and with what parameters. Examine the installing account to ensure it's an authorized administrative account operating during approved maintenance windows.
Attack patterns
- Ryuk ransomware installs services with random names to execute encryption routines with SYSTEM privileges across enterprises
- APT41 group uses services for persistence, installing backdoors as services that beacon to command-and-control infrastructure
- PsExec lateral movement creates ephemeral PSEXESVC services, visible in 4697 events during active attacker operations
Compared withEvent 4697 and System Event 7045 record roughly the same service-install fields (service name, file path, type, start type and account). The difference that matters is coverage: 7045 is written to the System log by the Service Control Manager by default, while 4697 only appears in the Security log when the 'Audit Security System Extension' subcategory is enabled. If that subcategory is off, 7045 may be your only record of a new service. 4697 does add SubjectLogonId, which lets you pivot to the installer's 4624.
Pull this event
Retrieval queries for a live host, a collected .evtx file and common SIEMs. Filter further on the key fields above.
Get-WinEvent -LogName 'Security' -FilterXPath "*[System[(EventID=4697)]]" -MaxEvents 50 |
Select-Object TimeCreated, Id, MachineName, Message-FilterXPath supports exact matches only. For substring matching, filter in Where-Object.
Where it shows up
Investigations, attack signals and lateral movement techniques that rely on this event.
- Attack signalService persistenceA service was installed (Security log equivalent, when enabled).
- Lateral movementPsExec and service-based executionDestination: Service install recorded in the Security log when the Security System Extension subcategory is on.
- Lateral movementsmbexecDestination: The same service install in the Security log when the Security System Extension subcategory is on.
- Lateral movementRemote service creationDestination: Service install in the Security log when the Security System Extension subcategory is enabled.
- InvestigationWhat persistence did the attacker create?Services
ATT&CK mapping
Techniques this event can help detect. Most of these depend on specific field values; the event alone does not mean the technique happened.
Related events
Common questions
- What does Windows event ID 4697 mean?
- Event 4697 logs the installation of new Windows services, a common technique for persistence, privilege escalation, and malware execution. Services run with SYSTEM privileges and survive reboots, making them attractive to attackers. Monitor this event to detect malicious service installation.
- Is event 4697 logged by default?
- No. It must be enabled before it is recorded. It is controlled by the "Security System Extension" Advanced Audit Policy subcategory (System).
- Where is event 4697 recorded?
- In the Security channel on the target host.
Decode a real event
Paste the XML and every value gets explained. Nothing leaves your browser.
Open decoderEvent 4697 logs the installation of new Windows services, a common technique for persistence, privilege escalation, and malware execution. Services run with SYSTEM privileges and survive reboots, making them attractive to attackers. Monitor this event to detect malicious service installation.