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.
Solution 4
The wmic
command in Command Prompt can retrieve this information. However in order for the clients to respond, a firewall rule is first required.
I found a post on community.spiceworks.com, thanks to MacKingTosh that seems to fix the error 'error - RPC server is unavailable'.
The command to run on the clients which produce this error is:
netsh firewall set service remoteadmin enable
You may want to check that this complies with your firewall polices.
When using wmic
, here is a breakdown of the parameters you can pass in:
/node
: - the servers that the alias will operate againstyourpcname
- the name of the PCcomputersystem
- it's a computer system that we are trying to get information aboutget
- we want to get the informationusername
- the user that is logged onmodel
- the model of the computermanufacturer
- the name of the company who made the computername
- the name of the PC
Some examples:
Get a username:
wmic /node: 'yourpcname' computersystem get username
Get a PC make and model:
wmic /node: 'yourpcname' computersystem get manufacturer, model
Get all three:
wmic /node: 'yourpcname' computersystem get manufacturer, model, username
Adding extra fields can be done using a comma and a space:
Model, manufacturer, username, name
The examples above are for a PC that is remote and the query is carried out over the network. If the command is run locally then it would have a slightly different syntax. For example:
wmic computersystem get manufacturer, model, username
Related videos on Youtube
pgodar
Updated on September 18, 2022Comments
-
pgodar over 1 year
From my Windows 7 PC, I want to check to see who is “actively” logged on to another Windows 7 PC on my network, not who connected last. How can this be done?
Throughout the day several people will remotely logon to a shared computer, generally logging off when they are through. Note, these users have Admin rights on both, their PC and the one they remote into. If I logon while someone else is actively logged on, I’m given the option to continue on and make myself the “active” user, thus placing the former active account into a disconnected state. It would be nice to have the ability to see who is actively logged on before making this choice.
I have searched the web and found various solutions that let you know who made the last connection, which does not translate into them being the last, or currently "active" user.
On a side note, it seems weird in Windows 7 that the current, active user's ID is displayed 'after' I click 'Yes' to login over them. When we were using Windows XP, one could see the ID of the current active user 'before' deciding to continue logging on.
Any help is appreciated.
-
I say Reinstate Monica over 6 yearsThe one (rare) case when this won't work is if the remote machine's shell isn't
explorer.exe
. Rare, but possible. -
I say Reinstate Monica over 6 yearsIt's worth noting that PSLoggedOn requires the
Remote Registry Service
to be running on the target computer. This service is not started by default.