How can I query the Log on as user of a Windows service using the command line?

Currently sc query shows service name, display name and other attributes of the services installed on my box. However it does not tell me what the Log on as setting is. How can I get this information using the command line?


sc query queries the current state; use sc qc to read the configuration.

C:\>sc qc messenger
[SC] GetServiceConfig SUCCESS

SERVICE_NAME: messenger
        TYPE               : 20  WIN32_SHARE_PROCESS
        START_TYPE         : 4   DISABLED
        ERROR_CONTROL      : 1   NORMAL
        BINARY_PATH_NAME   : C:\WINDOWS\system32\svchost.exe -k netsvcs
        LOAD_ORDER_GROUP   :
        TAG                : 0
        DISPLAY_NAME       : Messenger
        DEPENDENCIES       : LanmanWorkstation
                           : NetBIOS
                           : PlugPlay
                           : RpcSS
        SERVICE_START_NAME : LocalSystem

You can use "WMIC" (WMI Command Line Interface) for this:

wmic service where name="Power" get StartName

StartName LocalSystem

Here's an example for a different service:

wmic service where name="RpcSS" get StartName

StartName NT AUTHORITY\NetworkService