Skip to main content
4697SecuritySystemSecurity tier 1

Event ID 4697: A service was installed in the system

Event ID 4697 records that a service was installed, written to the Security log by the Audit Security System Extension subcategory. It adds what 7045 lacks: the account and logon session that performed the install. Alert on a service binary outside the Windows and Program Files folders, kernel driver types, and accounts other than LocalSystem.

What Triggers Event 4697 and How It Differs from 7045

Event 4697 is written when a new service is installed on the system. It comes from the Audit Security System Extension subcategory, and Microsoft lists Windows Server 2016 and Windows 10 as the minimum operating systems. That one detail explains a common complaint: on older servers there is no 4697 to find. The other record of the same moment is event 7045, written to the System log by the Service Control Manager. People compare the two constantly, and in our Search Console data the queries "event id 4697 vs 7045" and "event id 7045 vs 4697" both show up.

For investigations, the difference is the Subject block. 4697 names the account that performed the installation, with SubjectUserSid, SubjectUserName, SubjectDomainName and SubjectLogonId. The logon ID takes you to the 4624 for that session, so you can see whether the install came from a console, a remote desktop or a network logon. It also lives in the Security log, which is usually protected and forwarded more strictly than the System log. When both logs are collected, treat the pair as a cross-check: one without the other points to a collection gap or to log tampering.

The service fields are precise. ServiceName is the name. ServiceFileName is the fully rooted path the Service Control Manager will execute, including any command-line parameters, so a service wired to cmd.exe /c or PowerShell shows its arguments right there. Microsoft warns that it records the path at creation only; if the path is changed afterwards, nothing is logged, and you have to track the change through process creation events. ServiceType is a hexadecimal value: 0x1 kernel driver, 0x2 file system driver, 0x8 recognizer driver, 0x10 Win32 own process (the common case), 0x20 Win32 share process, and 0x110 and 0x120 for the interactive variants. ServiceStartType runs from 0 (boot) and 1 (system), both for drivers, through 2 (automatic) and 3 (manual) to 4 (disabled). ServiceAccount is populated only for Win32 own and share process services, and LocalSystem is used when none is supplied. A later account change is not logged either.

Microsoft turns those fields into five rules, and they are a good detection starting point. Report every service whose file name is not under %windir% or the Program Files folders. Report service types 0x1, 0x2 and 0x8, which start first and get almost unlimited access to the operating system. Report start types 0 and 1, which only drivers use. Report start type 4, since installing a service already disabled is unusual. And report any service account other than localSystem, localService or networkService, because that identifies services running under a user account.

The sample deliberately shows where those rules stop. It continues the PsExec example used for event 5145: adm.lopez, under the same logon session 0x5d21b8, installs PSEXESVC with a Win32 own process type, manual start and LocalSystem. The binary lives in %SystemRoot%, because PsExec-style tools copy it through ADMIN$, which maps to the Windows folder. Rule one never fires on it. What gives it away is context: a remote installation under a network logon from a workstation address, a service name that does not belong to any software you deploy, and a 5145 write to ADMIN$ a few seconds earlier. MITRE tracks the persistence side as T1543.003 (Windows Service) and the execution side as T1569.002 (Service Execution).

Services get created three ways: sc.exe or the PowerShell New-Service cmdlet on the host, the Service Control Manager API from a program, and remotely through RPC. The remote route reaches the target over the svcctl named pipe on IPC$, which is the RelativeTargetName you will see in a 5145 for that pipe moments before the 4697. So a 5145 with svcctl followed by a 4697 under the same network logon is a remote installation almost by definition, and the Subject tells you which account was used to do it.

Build the chain: the 4624 type 3 logon, the 5145 write of the binary, this 4697, and then a 4688 for the process the service launched. Each step has its own field set, and the logon ID is the thread that ties them together on the target host.

Event 4697 Fields

FieldWhat it tells youSimulated value
SubjectUserSidSID of the account that installed the service.S-1-5-21-424242-1050
SubjectUserNameName of the account that installed the service.adm.lopez
SubjectDomainNameDomain or computer name of the account.CORP
SubjectLogonIdLogon session ID; on a remote install this is the network logon on the target host.0x5d21b8
ServiceNameName of the installed service.PSEXESVC
ServiceFileNameFully rooted path the Service Control Manager runs, with any command-line parameters, as recorded at creation.%SystemRoot%\PSEXESVC.exe
ServiceTypeHexadecimal service type; 0x10 is Win32 own process.0x10
ServiceStartTypeStart type; 2 automatic, 3 manual, 4 disabled, 0 and 1 for drivers.3
ServiceAccountAccount the service runs as; only populated for Win32 own and share process services.LocalSystem

Inspect Event 4697 Values

Click a field to inspect the full simulated value, the way you would expand it in a SIEM event view.

Example Event 4697 Log

A representative Security entry for Event 4697, generated deterministically by our telemetry engine so every field holds a realistic, internally consistent value.

Simulated example generated by SOCSimulator Research
<Event xmlns="http://schemas.microsoft.com/win/2004/08/events/event">
  <System>
    <Provider Name="Microsoft-Windows-Security-Auditing" />
    <EventID>4697</EventID>
    <Version>0</Version>
    <Level>0</Level>
    <Task>0</Task>
    <Opcode>0</Opcode>
    <Keywords>0x8020000000000000</Keywords>
    <TimeCreated SystemTime="2025-01-19T14:38:07.000Z" />
    <EventRecordID>395280</EventRecordID>
    <Channel>Security</Channel>
    <Computer>WS-SIM-001.corp.socsimulator.example</Computer>
    <Security />
  </System>
  <EventData>
    <Data Name="SubjectUserSid">S-1-5-21-424242-1050</Data>
    <Data Name="SubjectUserName">adm.lopez</Data>
    <Data Name="SubjectDomainName">CORP</Data>
    <Data Name="SubjectLogonId">0x5d21b8</Data>
    <Data Name="ServiceName">PSEXESVC</Data>
    <Data Name="ServiceFileName">%SystemRoot%\PSEXESVC.exe</Data>
    <Data Name="ServiceType">0x10</Data>
    <Data Name="ServiceStartType">3</Data>
    <Data Name="ServiceAccount">LocalSystem</Data>
  </EventData>
</Event>

Detecting Event 4697

Service binary outside the Windows and Program Files folders (Microsoft rule one)

SPL assumes sourcetype XmlWinEventLog:Security. The pattern allows a leading quote and the %windir% and %SystemRoot% forms. As the sample shows, this rule alone misses PsExec-style tools whose binary sits in the Windows folder; run the remote-install query as well.

index=wineventlog sourcetype=XmlWinEventLog:Security EventCode=4697
| where NOT match(ServiceFileName, "(?i)^\"?(%windir%|%systemroot%|c:\\\\windows|c:\\\\program files)")
| table _time, host, SubjectUserName, SubjectLogonId, ServiceName, ServiceFileName, ServiceAccount

Service installed under a user account (not LocalSystem, LocalService or NetworkService)

Microsoft's rule five. ServiceAccount is empty for kernel drivers, so the filter requires a value.

index=wineventlog sourcetype=XmlWinEventLog:Security EventCode=4697 ServiceAccount=* NOT ServiceAccount IN ("LocalSystem", "LocalService", "NetworkService", "NT AUTHORITY\\LocalService", "NT AUTHORITY\\NetworkService")
| table _time, host, SubjectUserName, ServiceName, ServiceFileName, ServiceAccount

Kernel, file system or recognizer driver types, or boot and system start types

Microsoft's rules two and three. These types start before almost everything else and are rarely installed outside planned driver rollouts.

index=wineventlog sourcetype=XmlWinEventLog:Security EventCode=4697 (ServiceType IN ("0x1", "0x2", "0x8") OR ServiceStartType IN ("0", "1"))
| table _time, host, SubjectUserName, ServiceName, ServiceFileName, ServiceType, ServiceStartType

Service installed under a network logon (remote installation)

Joins the 4697 to the 4624 type 3 logon on the same host and logon ID, which exposes the source address. Expect hits from software deployment and management servers; exclude them by source address.

index=wineventlog sourcetype=XmlWinEventLog:Security ((EventCode=4697) OR (EventCode=4624 LogonType=3))
| eval logon_id=coalesce(SubjectLogonId, TargetLogonId)
| stats values(EventCode) as codes, values(IpAddress) as src, values(ServiceName) as svc, values(ServiceFileName) as bin by host, logon_id
| where isnotnull(mvfind(codes, "4697")) AND isnotnull(mvfind(codes, "4624"))

True Positive vs False Positive

Plenty of installs are routine. Installers and updaters running as SYSTEM add services all the time, and Microsoft's own sample shows the machine account as the Subject with the LocalSystem SID. Vendor drivers for printers, VPN clients and endpoint agents arrive with kernel types and early start values and are legitimate when they come from a managed rollout. Keep a baseline of ServiceName plus ServiceFileName plus signer for your standard images, and compare new hosts to it.

The shapes that deserve attention are narrower. A Subject that is a person or a service account authenticated over the network, not the SYSTEM account at the console. A ServiceFileName with command interpreters, scripting hosts or rundll32 in the path field. A path under Users, ProgramData or Temp. A random-looking ServiceName. A ServiceAccount that is a domain user. A kernel driver type installed outside a maintenance window. Any one of these is a prompt; two together is usually enough to open a case.

Do not let the Subject mislead you when it is a machine account. Microsoft's sample shows the computer's own account with the SYSTEM logon ID, which means a process already running as SYSTEM did the install, and the human behind it is not in this event. Go to the parent chain of that process. And when you write an allowlist, key it on the signer and hash of the binary as well as the service name. Names are the cheapest thing for an attacker to copy, and a service called like a vendor agent costs nothing to register.

For triage, hash the binary and check its signature, then look at the parent chain in the 4688 for the service process. Verify how the Subject got onto the machine through the 4624. If the install was remote, pull the source address from that event and check what else that address touched in the preceding minutes. Because the path and account are logged only once, re-read the live service configuration on the host, since an attacker can change them after the 4697 fires.

MITRE ATT&CK® Techniques

Event 4697 telemetry feeds detections for these ATT&CK® techniques:

Practice Investigating Event 4697

Reading about a service was installed in the system is one thing. Working the detection inside a live console is another. These free SOCSimulator operations cover the attack techniques Event 4697 helps you detect:

Start investigating free

Frequently Asked Questions

What is the difference between event ID 4697 and 7045?
Both record a new service. 4697 is in the Security log, comes from the Audit Security System Extension subcategory, requires Windows Server 2016 or Windows 10 and later, and names the installing account and logon session. 7045 is in the System log from the Service Control Manager and works on older systems. Collect both and use them as a cross-check.
Why is there no event 4697 in my Security log?
Three common reasons: the host runs an operating system older than Windows Server 2016 or Windows 10, the Audit Security System Extension subcategory is not enabled for Success, or the log is not being collected from that host. Fall back to 7045 in the System log on older machines.
Which ServiceType and ServiceStartType values should I alert on?
Microsoft suggests reporting service types 0x1, 0x2 and 0x8 (kernel, file system and recognizer drivers), start types 0 and 1 (boot and system, used by drivers) and 4 (disabled). It also suggests reporting a ServiceFileName outside the Windows and Program Files folders and any account other than localSystem, localService or networkService.
Does event 4697 record changes to an existing service?
No. It is logged when a service is installed. If the file path or account is changed afterwards, nothing is logged. Microsoft recommends tracking those changes through process creation events, and you can re-read the live service configuration on the host.

Sources

“4697 fields, ServiceType and ServiceStartType value tables, minimum OS version, notes on path and account not being re-logged, and Microsoft's five monitoring rules”

“Windows Service (T1543.003): creating or modifying Windows services to repeatedly execute payloads for persistence”

“Service Execution (T1569.002): abusing the Service Control Manager to execute commands or payloads”

“5145 ADMIN$ share access used in the remote installation chain; ShareName and RelativeTargetName fields”

Event ID

Event ID 7045: A Service Was Installed in the System

Event ID 7045, "A service was installed in the system": fields, PsExec and bad ImagePath triage, benign driver installs,…

Read more
Event ID

Event ID 1102: Audit Log Cleared & How to Detect It

Event ID 1102 fires whenever the Windows Security log is cleared. Learn who cleared it, why it demands investigation, an…

Read more
Glossary

What is Log Management? SOC Glossary

Log management is the process of generating, collecting, storing, protecting and finally deleting the records your syste…

Read more
Glossary

What is Persistence? SOC Glossary

Persistence is the set of techniques an adversary uses to keep access to a compromised system after whatever gave them t…

Read more
Glossary

What is Incident Response? SOC Glossary

Incident response (IR) is how a security team detects, contains, removes and recovers from an incident, then learns from…

Read more
Career Path

SOC Analyst (Tier 2) Career Guide: Salary & Skills

Tier 2 SOC Analysts handle the investigations that Tier 1 escalates. You dig into multi-stage attacks, coordinate contai…

Read more
Career Path

Incident Responder Career Guide: Salary & Skills

Incident Responders lead the technical response when confirmed breaches happen. You coordinate containment, run forensic…

Read more
Technique

Create or Modify System Process (T1543): Detection Training

Create or Modify System Process establishes persistence by installing a new service or altering an existing one so a pay…

Read more
Technique

System Services (T1569): Detection Training

This technique executes code by creating or starting system services and daemons, which run with high privilege and can …

Read more
Comparison

SOCSimulator vs. LetsDefend: Platform Comparison

SOCSimulator wins on operational realism. You get multi-tool shift simulation with SLA pressure, noise injection, and al…

Read more
Event ID

Windows Event ID Library: SOC Reference

Windows Security and Sysmon event IDs with simulated log samples, field tables, and tested detection queries.

Read more
Feature

Shift Mode: Real-Time SOC Simulation

Practice alert triage under realistic time pressure with SLA timers and noise injection.

Read more