who
:
qwinsta query station
w
, finger
:
quser query user
É possível escrever uma ferramenta personalizada usando WTSEnumerateSessions()
e WTSQuerySessionInformation()
- muito fácil de usar via Python com 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