Retrieve IP address of Local PC connected to Remote Desktop
6,169
The CLIENTNAME environment variable holds the name of the client machine. Your IP addresses look like private IPs, so if the client & server are on the same network, you could capture the output of one of these commands
nslookup %CLIENTNAME%
ping %CLIENTNAME%
tracert %CLIENTNAME% | find "Tracing"
Related videos on Youtube
Author by
Igor L.
Updated on September 18, 2022Comments
-
Igor L. over 1 year
I am running Windows7 on Local PC and Remote Desktop (don't have admin rights on either).
Say the IP address of my PC is 10.*.4.*1
When I connect to a remote desktop, using netstat I am able to retrieve all the 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
Printing
echo %username%
I am able to get the account I am connected to on the Remote Desktop.I would like to echo the IP address of my Local PC with which I am connected to the Remote Desktop.
-
acejavelin almost 8 yearsPossible duplicate of superuser.com/questions/1078181/…
-
Igor L. almost 8 yearsThis is a simillar, yet unrelated question - the first one asks for a list of all connected ip addresses and their current accounts on the remote desktop. This question asks how to print ip address of the local PC a user is using to connect to the said remote desktop.
-
acejavelin almost 8 yearsI'll let the mods figure out if it is duplicate or not, because the end result of these two questions seems nearly the same, but for one user instead of all, you want to get IP address and user account of connected user.
-
Igor L. almost 8 yearsAs u wish, but I expect the method of retrieving the data to be different
-
acejavelin almost 8 yearsLook at the CLIENTNAME and resolve backwards.
-
-
Igor L. almost 8 yearsThanks a ton, works perfectly. Can u pls check also the linked question? The architecture of the program I'm trying to write would be simpler if I was able to achieve what is specified in that question. -> superuser.com/questions/1078181/…
-
user2305193 over 6 yearsis there a way without using %clientname%? In my situtation this does not work!