简体   繁体   中英

Terminal Services command “Query Session” in C#

I'm looking to retrieve this information using C#. I know that I can Shell out and execute these commands, but I'm hoping that I can do it all through System.Diagnostic namespace... 在此处输入图片说明

Cassia did the trick for me...

From the link listed above, and thans to Alex K for pointing me in the right direction, I just didn't was to do any p/invoke without a covering library.

Cassia supports the following operations on both local and remote terminal servers: * Enumerating terminal sessions and reporting session information including connection state, user name, client name, client display details, client-reported IP address, and client build number (WTSEnumerateSessions, WTSQuerySessionInformation, and friends) * Logging off a session (WTSLogoffSession) * Disconnecting a session (WTSDisconnectSession) * Displaying a message box in a session and getting a response from the user (WTSSendMessage) * Enumerating all processes (WTSEnumerateProcesses) * Killing a process (WTSTerminateProcess) * Shutting down or rebooting the server (WTSShutdownSystem) In addition, Cassia supports enumerating all terminal servers on a domain (WTSEnumerateServers).

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