How can I tell who is actively logged on (locally or remotely) a Windows 7 PC?

Solution 1:

You can use the Terminal Services query command for this.

query session /server:remote_computer_name_here

Note that you will need to set the following registry value on the remote computer:

Key: HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Terminal Server
Value Name: AllowRemoteRPC
Value: 1
Type: REG_DWORD

You could put the query command in a batch file, so users can just double click it to see who is logged into that computer.

Solution 2:

You could use the Windows Sysinternals tool PSLoggedOn.

Usage: psloggedon [- ] [-l] [-x] [\\computername | username]

- Displays the supported options and the units of measurement used for output values.

-l Shows only local logons instead of both local and network resource logons.

-x Don't show logon times.

\\computername Specifies the name of the computer for which to list logon information.

username If you specify a user name PsLoggedOn searches the network for computers to which that user is logged on. This is useful if you want to ensure that a particular user is not logged on when you are about to change their user profile configuration.

Solution 3:

Another option from the Windows 7 or higher command line:

tasklist /s computername /fi "imagename eq explorer.exe" /v

You may be prompted for admin-level credentials if querying a remote machine.

This will see if explorer.exe is running on a machine, and "/v" provides the username. If a machine is not logged in, no explorer.exe process will be running. If someone is logged on, the explorer.exe process runs in the context of that user.