by Ryan
16. January 2013 11:42
In my last post, I showed how to get RDP/TS session information from a local or remote computer, including ClientName, on the command line using Powershell. (But it's not really Powershell. It's a PS wrapper around some C# that P/Invokes a native API. Which is pretty nuts but it works.) Since I can't think of any other way to get this information on the command line, I thought it would be useful to convert the thing to native code. I named the program users.exe. It's written in C. Here is what it looks like:
C:\Users\joe\Desktop>users /?
USAGE: users.exe [hostname]
Not specifying a hostname implies localhost.
This command will return information about users currently logged onto
a local or remote computer, including the client's hostname and IP.
Users.exe was written by Ryan Ries.
C:\Users\joe\>users SERVER01
Session ID : 0
Domain\User : System
Client Name : Local
Net Address : n/a
Conn. State : Disconnected
Session ID : 1
Domain\User : System
Client Name : Local
Net Address : n/a
Conn. State : Connected
Session ID : 25
Domain\User : DOMAIN\joe
Client Name : JOESLAPTOP
Net Address : 10.122.124.21 (AF_INET)
Conn. State : Active
I had a pretty rough time shaking the rust off of my native/unmanaged code skills, but I pulled it off. That said, if you wanna give it a try, I would very much appreciate any bug reports/feature requests.
users.exe (63.50 kb)