Question

Has anyone ever come across a way of a way to create an app that kind of mimics what Terminal Services manager does in Windows2003/XP.

I would like to write something that would either go and query a farm of server every n secs a get me a list of users logged in, there process's etc or do maybe type a username in and it goes and finds the user in the farm and returns their details.

Cheers Luke

Was it helpful?

Solution

I would suggest using Cassia, a .NET library which uses internally the Wtsapi32 library Arnshea mentioned. For example, to list all users logged into a server:

Dim manager As New TerminalServicesManager()
Using server As ITerminalServer = manager.GetRemoteServer("your-server-name")
    server.Open()
    For Each session As ITerminalServicesSession In server.GetSessions()
        If Not string.IsNullOrEmpty(session.UserName) Then Console.WriteLine(session.UserName)
    Next
End Using

OTHER TIPS

I've hacked this using qwinsta (query winstation is the mnemonic) and string parsing/regular expressions. Beware of firewalls and impersonation.

Take a look at psexec and the other ps* utilities from Microsoft (originally from SysInternals).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top