简体   繁体   中英

Check whether there is a user on the console/interactive session from a .NET Windows Service

I am writing a service that performs a certain operation that only makes sense if a user is interactively logged onto the console session (that is, if somebody is physically at the machine). I have found that, on Windows 7, WTSGetActiveConsoleSessionId returns the session ID of the console session even if no user is logged onto it but there is a user logged on with Remote Desktop.

There are some processes running under the console session, even though nobody has logged on at the physical console since the computer was rebooted. However, Task Manager does not list that session ID in the Users tab.

How do I check whether there is an interactive logon in the console session?

Boolean Environment.UserInteractive

在这里回答: 如何知道Windows会话是否是交互式会话?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM