Sign up ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Without using something like cygwin, is there a way to find out everyone who is logged-into a Windows server form the command-line?

share|improve this question
I did not see anything like it listed here:… – warren May 1 '10 at 20:09

4 Answers 4

up vote 4 down vote accepted


query station

w, finger:

query user

It is possible to write a custom tool using WTSEnumerateSessions() and WTSQuerySessionInformation() - very easy to use via Python with PyWin32:

import win32ts
protocols = {
    win32ts.WTS_PROTOCOL_TYPE_CONSOLE: "console",
    win32ts.WTS_PROTOCOL_TYPE_ICA: "citrix",
    win32ts.WTS_PROTOCOL_TYPE_RDP: "rdp",

## alternatively, hServer = win32ts.WTSOpenServer("hostname")

currentSessId = win32ts.WTSGetActiveConsoleSessionId()
for session in win32ts.WTSEnumerateSessions(hServer):
    sessionId = session["SessionId"]
    session["UserName"] = win32ts.WTSQuerySessionInformation(hServer, sessionId, win32ts.WTSUserName)
    session["WinStationName"] = session["WinStationName"] or "(disconnected)"
    session["Protocol"] = win32ts.WTSQuerySessionInformation(hServer, sessionId, win32ts.WTSClientProtocolType)
    session["ProtocolName"] = protocols.get(session["Protocol"], "unknown")
    print "%(UserName)-20s %(WinStationName)s (%(ProtocolName)s/%(SessionId)d)" % session
share|improve this answer


WMIC /Node:remotecomputer ComputerSystem Get UserName

For example

WMIC /Node: ComputerSystem Get UserName

More information:

share|improve this answer
Nice. Have not heard of WMIC. – gravyface May 1 '10 at 20:42

Have a look at Microsofts Sysinternals tool PSLoggedOn

share|improve this answer

type in query user or query user /server:remoteserver for a list of currently logged in users. This will also tell you how they are logged in. This works on standalone servers and workstations as well as terminal servers

share|improve this answer
Can you post a link to some documentation? – Dennis Williamson May 1 '10 at 23:13
Dennis the docs are here:… There is just a bit more there than query /?. I use qwinsta more often. – railmeat May 2 '10 at 1:51

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.