views:

251

answers:

3

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

+1  A: 

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

Arnshea
i saw this but it looked a bit clumsy, is the no API available?
beakersoft
There is (wtsapi32.dll) but there's a bit of a learning curve and it's use will vary depending on the environment in which it's run. It's a COM/ActiveX api but you're out of luck when it comes to tlbs...
Arnshea
A: 

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

jdigital
+2  A: 

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
Dan Ports
Looks exactly what I need, thanks a lot!
beakersoft