If you’re wondering how to find out who is currently logged into a Microsoft Windows computer, there are several ways to proceed. Here are a few common methods you can use from a remote computer or logged into the local computer you are querying.
WhoAmI Command
The “whoami” command displays the user you are currently logged in and using in Windows.
- Hold down the Windows Key, and press “R” to bring up the Run window.
- Type “CMD“, then press “Enter” to open a command prompt.
- At the command prompt, type the following then press “Enter“:
whoami
- The computer name or domain followed by the username is displayed.
Query User Command
This command allows you to see all users currently logged into the computer.
Locally
- Hold down the Windows Key, and press “R” to bring up the Run window.
- Type “CMD“, then press “Enter” to open a command prompt.
- At the command prompt, type the following then press “Enter“:
query user
- The computer name or domain followed by the username is displayed.
Remotely
- Hold down the Windows Key, and press “R” to bring up the Run window.
- Type “CMD“, then press “Enter” to open a command prompt.
- At the command prompt, type the following then press “Enter“:
query user /server:computername
Replace “computername” with the actual computer name of the system you are querying. You can also use the IP Address of the computer.
- The computer name or domain followed by the username is displayed.
Task Manager
- Right-click the taskbar, then select “Task Manager“.
- Select the “Users” tab.
- Details on the users logged into the machine are displayed.
WMIC
- Hold down the Windows Key, and press “R” to bring up the Run window.
- Type “CMD“, then press “Enter” to open a command prompt.
- At the command prompt, type the following then press “Enter“:
WMIC /NODE:"computername" COMPUTERSYSTEM GET USERNAME
Replace “computername” with the actual computer name of the system you are querying. You can also replace “computername” with the IP address of the system.
WMIC /NODE:192.168.1.1 COMPUTERSYSTEM GET USERNAME
Jennifer says
‘query’ is not recognized as an internal or external command,
operable program or batch file.
Raphael Ferreira says
Plain, simple, and it works. At least in my case. I used the “query user /server:computername” method, as I needed to know who was logged in to a remote machine name I did not recognize… Then when seeing the username I knew who it was (in this case who the computer belonged to). THANKS! Great tip! R.
Tom says
“At the command prompt, type the following then press “Enter“:
query user /server:computername
Replace “computername” with the actual computer name of the system you are querying.”
I got: The RPC server is unavailable.
This did not work for me, but exchanging “computername” with the machine’s IP worked just fine.
idan says
This way only gives you one user ,
but what if i got more users logged on ?
mveras says
One important distinction that needs to be made here is that the “whoami” command does not return who is logged in. It returns who is running the “whoami” command. Which means that if you are running this command as a different user than whoever is actually logged in (like when you are executing remotely, it is completely useless.
“query user” on the other hand, returns who is actually logged in regardless who is running the “query user”
The WMIC command lacks one nice feature that “query user” has: the time the user logged in.
Harry S. Anchan says
Another easy way that i use. Just right-click on the Task bar or C-A-D, bring up Task Manager and click on the Users tab.
eK says
Worked for me, thank you!
samiuddin says
Great contribution! it helped alot
Phil says
I tried this and both the remote query and WMIC methods returned the error below in my domain…
I am guessing this is a windows firewall issue ?
The RPC server is unavailable.
Regards, Phil
Jvonne says
Thank you much! Like Noel, other cmds like ‘wmic.exe’ and ‘netsh’ and ‘net user’ would not work for remote PC’s on the network, but the ‘query user’ command worked great for me!
Mohammed Saeed says
It was very handy. saved my day. Thank you very much,
Jeroen says
yes, very usefull,
I’m wondering (maybe it will go to far) but is there a way to logout some users, like if you’re going to do an update or so.
thanks
Noel says
Yes, this did help, and it worked on a Windows 10 PC’s on a domain. Other suggestions by other people such as ‘wmic.exe’ and ‘netsh’ and ‘net user’ would not work for remote PC’s on the network, but the ‘query user’ command worked great for me, thanks a lot.
steelersc says
Worked well when run against windows server
Tony says
A very helpful page, thank you
Mark says
Tom, did you ever find an answer to this? I’m interested in exactly this, finding out who (if anyone) is logged in before I log in myself. Unfortunately, even if the last user actually logged out, his name will be presented by the prompt for the next login (a “convenience”, I suppose, but it hides whether or not that user is actually still logged in or not).
prerna says
WMIC /NODE:”computername” COMPUTERSYSTEM GET USERNAME
will return “UserName” string instead of actual logged in user name in windows 10 and widows server 2012
Tom says
How about from the lock screen? Say if you want to check if anyone else is logged in before logging in to install updates that are going to require a system restart?