How do I get the command-line arguments of a Windows service?

There are two types of arguments for services:

  • Arguments that were passed on the process start command line. You can get to those easily using Process Explorer, etc.
  • Arguments that were passed to the ServiceMain function. This is the WIndows API that a service is supposed to implement. The .NET equivalent is ServiceBase.OnStart. This is what is used when you do an SC START \[arguments\]. This has nothing to do with "command line process arguments".

The second type of parameters is probably only known by the service itself, if the implementation makes any use of it which is not the case for many services. I don't think Windows keep track of this when we look at low level Windows structures like the PEB: Process and Thread Structures (MSDN), even the undocumented parts of it, Undocumented functions of NTDLL.


You can find the service EXE file details and edit or just see the commandline options in the registry entry for the service. You'll find that under

HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\services

Be sure to restart the Services window if you decide to change this as it won't reread it live.


Try the Process Explorer application from Sysinternals

It is like Task Manager, only it lists all the running processes. Select your service and see its properties.