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

link|improve this question

I did not see anything like it listed here: serverfault.com/questions/3780/… – warren May 1 '10 at 20:09
feedback

4 Answers

up vote 2 down vote accepted

who:

qwinsta
query station

w, finger:

quser
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")
hServer = win32ts.WTS_CURRENT_SERVER_HANDLE

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
link|improve this answer
feedback

Try

WMIC /Node:remotecomputer ComputerSystem Get UserName

For example

WMIC /Node:127.0.0.1 ComputerSystem Get UserName

More information:

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

Have a look at Microsofts Sysinternals tool PSLoggedOn

link|improve this answer
feedback

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

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

Your Answer

 
or
required, but never shown

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