Match account/ipaddress of users connected to a remote desktop

command lineremote desktopuser-accountswindows 7

The remote desktop is running on Windows7. I do not have admin rights.

Using nestat I am able to get a list of all remotely connected IP Addresses:

C:\>netstat -n | find "3389" | find "ESTABLISHED"
  TCP    10.*.4.10:3389        10.*.4.*1:50031       ESTABLISHED
  TCP    10.*.4.10:3389        10.*.4.*2:50032       ESTABLISHED
  TCP    10.*.4.10:3389        10.*.4.*3:50033       ESTABLISHED
  TCP    10.*.4.10:3389        10.*.4.*4:50034       ESTABLISHED
  TCP    10.*.4.10:3389        10.*.4.*5:50035       ESTABLISHED

On the PC we have several accounts (e.g. USER1, USER2, USER3, USER4, USER5).

I am writing a program that will require as an input a list of these users mapped to the account they are currently logged into – I need to be able to do this from command prompt.

The desired output could look like this:

(the format is really not that important, if I get the info in any way I will handle it somehow)

  10.*.4.*1:50031        USER1
  10.*.4.*2:50032        USER2
  10.*.4.*3:50033        USER3
  10.*.4.*4:50034        USER4
  10.*.4.*5:50035        USER5

Best Answer

This may get you going in the right direction, though it only provides data for the "current" user:

tracert %CLIENTNAME% | find "Tracing" > %TEMP%\ip.txt
set CLIENTIPINFO=<%TEMP%\ip.txt
echo %USERNAME% - %CLIENTIPINFO%

Perhaps a third party utility would be useful? I can't vouch for the reliability of this app, but it worked on one of our dev servers: http://home.fnal.gov/~jklemenc/tslistusers.html

Related Question