用户可以直接在 Microsoft Vista 上与服务交互吗?
从 Microsoft 网站(请参阅 msdn.microsoft.com/en -us/library/ms683502(VS.85).aspx) 它明确表示“从 Windows Vista 开始,服务无法直接与用户交互”。
所以我决定使用“psexec -s cmd.exe”来测试它。 据我所知,“psexec”创建一个服务以打开命令提示符。 不用说它有效。 然后我决定结合使用“EnumWinSta GUI”和 psexec 来切换到 winlogon 桌面。 令我惊讶的是,我什至可以在此桌面上启动“cmd.exe”。 这是否意味着从服务创建的新进程可以是交互式的?
或者是因为 psexec 做了某种黑魔法? 如果是的话它是如何做到的?
我正在尝试将全屏窗口从服务显示到 Vista 和 XP 中的 winlogon 桌面对象中。
From the Microsoft website (see msdn.microsoft.com/en-us/library/ms683502(VS.85).aspx) it clearly says "Services cannot directly interact with a user as of Windows Vista".
So I decided to test this by using "psexec -s cmd.exe". As far as I know, "psexec" creates a service in order to open a command prompt. Needless to say it worked. I then decided to use "EnumWinSta GUI" in combination with psexec to switch to the winlogon desktop. To my surprise, I could even start "cmd.exe" on this desktop. Does this mean a new process created from a service can be interactive?
Or is it because psexec does some kind of black magic? If so how does it do it?
I am trying to display a full screen window from a service into the winlogon desktop object in Vista as well as XP.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
服务中运行的代码无法直接与交互式会话交互。
但是,作为具有足够权限的服务运行的代码可以创建在特定用户桌面中运行的新进程 - 例如,获取交互式会话的用户令牌并调用 CreateProcessAsUser。
您可以使用 WTSGetActiveConsoleSessionId 获取活动控制台会话,即实际在计算机上的用户的会话。 然后可以使用 WTSQueryUserToken 来获取令牌。
您的服务还可以在其处理函数中使用会话更改通知来查看用户何时登录/注销、解锁其会话等。
Code running within a service cannot directly interact with an interactive session.
However, code running as a service with sufficient privileges can create a new process running within a specific user's desktop - getting the interactive session's user's token and calling CreateProcessAsUser, for example.
You can use WTSGetActiveConsoleSessionId to get the active console session, the session of the user who is actually on the machine. WTSQueryUserToken can then be used to get the token.
Your service can also use session change notifications in its handler function to see when users logon/logoff, unlock their session, and so on.