Thursday, 17 May 2018

windows - Get hostname of a RDP client computer


I have a question which I'm sure has a simple solution, but it keeps eluding me.


There's a server in the picture that is used by several people.
All of them use the same account to log in.
The only way to differentiate sessions would be by hostname or IP.


So - How to see, on the remote computer, a hostname of the client connected?


For example, I RDP in to the server 256.12.13.1 from my IP 256.12.13.7.
Is there a command I could run on the server in that remote session that will output 256.12.13.7?


I ask because it would be good if that command would output 256.12.13.9 when person connects from that other IP.


So I can put it in startup and whenever someone connects script like this would run:


gethostname >> rdplog.txt
date /t >> rdplog.txt
time /t >> rdplog.txt

So this can basically equal to a very simple login log.



Answer



You could write a batch script like:


netstat -na | find "3389" | find "ESTABLISHED" >> C:\path_to_rdplog.txt
date /T >> C:\path_to_rdplog.txt
time /T >> C:\path_to_rdplog.txt
echo. >> C:\path_to_rdplog.txt
echo ----------- >> C:\path_to_rdplog.txt
echo. >> C:\path_to_rdplog.txt

You just have to make sure that the person who's logging in has write permissions to C:\path_to_rdplog.txt


No comments:

Post a Comment

Where does Skype save my contact's avatars in Linux?

I'm using Skype on Linux. Where can I find images cached by skype of my contact's avatars? Answer I wanted to get those Skype avat...