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



When working in a Windows environment, it is often necessary to know who is logged on as a user of a particular service. Knowing who is logged on can help in troubleshooting and diagnosing problems with a service, as well as providing a better understanding of who is using the service and for what purpose. The following article provides a guide on how to use the command line to query the log on as user of a Windows service.

The first step is to open a command prompt window. This can be done by pressing the Windows key + R to open the Run window, and then typing “cmd” and pressing Enter. This will open a command prompt window.

Once in the command prompt window, the command to query the log on as user of a service is “sc qc ”. The parameter should be replaced with the name of the service which you wish to query. This command will display the service name, type, start type, and the log on as user of the service. The log on as user will be listed as either “Local System”, “Local Service”, or a user name.

The next step is to use the command “net user ” to query the user name of the log on as user. The parameter should be replaced with the user name of the user which is logged on as the service. This command will display information about the user such as the full name, description, and groups that the user is a member of.

If the log on as user is a local system or local service account, then the command “net localgroup” can be used to query the group membership of the account. This command will list all of the groups that the local system or local service account is a member of.

Finally, the command “sc sdshow ” can be used to query the security descriptor of the service. This command will display the security descriptor, which contains information such as the service’s owner, the user or group which is allowed to start the service, and the users or groups which are granted access to the service.

In summary, the command line can be used to query the log on as user of a Windows service. This can be done by using the command “sc qc ” to query the log on as user, “net user ” to query the user name of the log on as user, and “net localgroup” and “sc sdshow ” to query the group membership and security descriptor of the service respectively. Knowing who is logged on as a user of a service can be helpful in troubleshooting and diagnosing problems, as well as providing a better understanding of who is using the service and for what purpose.

Inquire Now

Thank you! Your submission has been received!
Oops! Something went wrong while submitting the form.
Find your next full or part-time role here

ScaleDesk can either help you find your next full time gig or a part time side gig where you can create extra income!

Onboard with us once
Skip HR screening and go to the final interview with with only your resume and a video interview you never have to redo
Get paid electronically every month for the hours you work
We will be your reference even if you work for us once

IT Teams: Use ScaleDesk to augment your team

Schedule Demo