谁:
原文链接:https://www.f2er.com/windows/368191.htmlqwinsta query station
w,手指:
quser query user
可以使用WTSEnumerateSessions()
和WTSQuerySessionInformation()
编写自定义工具 – 通过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,win32ts.WTSClientProtocolType) session["ProtocolName"] = protocols.get(session["Protocol"],"unknown") print "%(UserName)-20s %(WinStationName)s (%(ProtocolName)s/%(SessionId)d)" % session