Windows – Get hostname of a RDP client computer

command lineremote desktopwindows

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 from my IP
Is there a command I could run on the server in that remote session that will output

I ask because it would be good if that command would output 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<br>
date /t >> rdplog.txt <br>
time /t >> rdplog.txt

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

Best 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