如何获得终端会话开始的通知
我想在终端服务启动时禁用应用程序。有没有一种方法可以注册某些服务,当有人远程登录时会发出通知?
I want to disable an app when terminal services start. Is there a way to register with some service that will notify when some logs in remotely?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
无法收到通知,但您可以定期检查 SystemInformation.TerminalServerSession 并采取相应措施。
但是,如果您的程序无法通过 RDP 运行,那么想要远程使用它的人将只能使用 VNC。或团队查看器。或者其他方法。我只想说,我认为不在 RDP 会话中远程工作甚至主动避免这样做是一种不好的行为或程序。
There is no way to get notified of it but you can periodically check SystemInformation.TerminalServerSession and act accordingly.
However, if your program doesn't work through RDP the people who want to use it remotely will just use VNC. Or TeamViewer. Or other methods. Suffice to say that I consider it poor behavior or a program to not work remotely in an RDP session and even actively avoiding to do so.
我建议您监听 WMI 围绕 RDP 对象引发的 ETW 事件,例如 Win32_SessionDirectorySession,Win32_Terminal、Win32_TSRemoteDesktop< /a> 等。有各种文章描述如何将 MOF 查询包装到 ETW 会话中:
I suggests you listen to ETW events raised by WMI around the RDP objects, like Win32_SessionDirectorySession, Win32_Terminal, Win32_TSRemoteDesktop and other. There are various articles describing how to wrap MOF queries into ETW sessions: