How to find a Windows service's exe path (PowerShell, sc, registry)
Codemia Knowledge Hub ·
In PowerShell, read the PathName property of Win32_Service. You can also run sc qc <ServiceName> or read the ImagePath registry value. A service stores the command it launches in its configuration, usually an executable path plus optional arguments.
PowerShell: PathName
Typical output:
For a custom service, PathName may include arguments too, for example "C:\Program Files\MyApp\service.exe" --config C:\MyApp\app.json. The Services UI is not a good source if you need this raw command line.
Command prompt: sc.exe
Read the BINARY_PATH_NAME line. That is the command line the Service Control Manager uses. This works where PowerShell is restricted or when you are already in a classic command prompt.
sc and the registry both expect the service name, not the display name, so a query by display name fails.
Registry: ImagePath
The configuration lives under HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\<ServiceName>, and the ImagePath value holds the executable plus arguments. You can read it without opening Registry Editor:
This is the same stored source the operating system uses, so it helps when higher-level tools are unavailable.
Getting only the .exe from the command line
PathName and ImagePath often include startup arguments, so don't treat the whole value as the executable. Take the first token, respecting quotes; splitting on the first space breaks paths under Program Files.
This works for many service definitions. For tooling that must handle arbitrary systems, use a proper command-line parser, because spaces and escaped quotes make naive splitting unreliable.
Services that run inside svchost.exe
Some services run in svchost.exe or another shared host process rather than a dedicated binary. The path you see is still correct for how the service process starts, but the actual service logic may be a DLL loaded by that host. So the path tells you what starts the process, not always which module implements the service.
Related reading
- How to fire EC2 instances and upload/run a startup script on each of them?
- How to fix a drifted AWS CloudFormation stack?
- How to fix NoHttpResponseException when running Wiremock on jenkins?
- How to force a redeploy with HELM
- How to fix 'Access Denied' while deleting empty S3 Elastic Beanstalk?
- How to fix App Store Connect Operation ERROR ITMS-90771
- How to force delete resources in a non-existant namespace?
- How to force 'docker login' command to ignore existing credentials helper?
System design interview problems on this topic
- Design a Metrics Monitoring and Alerting System: solution and walkthrough
- Design a Distributed Tracing System: solution and walkthrough
- Design a Code Deployment System: solution and walkthrough
- Design GitHub Actions: solution and walkthrough

System Design Fundamentals
Build a strong foundation in designing scalable, reliable distributed systems.
View the courseSystem Design practice on Codemia
Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.