是否有类似于’谁’或’w’的工具通过Windows上的命令行?

如果不使用像cygwin这样的东西,有没有办法找出从命令行登录到 Windows服务器的每个人?
谁:
qwinsta
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

相关文章

Windows2012R2备用域控搭建 前置操作 域控主域控的主dns:自...
主域控角色迁移和夺取(转载) 转载自:http://yupeizhi.blo...
Windows2012R2 NTP时间同步 Windows2012R2里没有了internet时...
Windows注册表操作基础代码 Windows下对注册表进行操作使用的...
黑客常用WinAPI函数整理之前的博客写了很多关于Windows编程的...
一个简单的Windows Socket可复用框架说起网络编程,无非是建...