Is there a way to determine if a user logged in via remote desktop
I'd like to determine if the currently logged in user is logged in by physically being at the computer of if they logged in via remote desktop.
I'm fine with limiting this to windows 7 if that helps.
I'm also fine with answers that determine this programatically or manually, though I would ultimatly prefer a programmatic answer.
The following solution works if you have cygwin installed. Running this script gives you output 'console' if you are running on a console, and 'rdp' if you are running in an rdp session:
#!/bin/bash # returns 'rdp' or 'console' current_session_line=`query session | grep '^>' $t | sed -e 's/>//'` current_session_type=`echo $current_session_line|sed -e 's/[- ].*//'` echo $current_session_type
You can determine whether the user is logged in locally or remotely via Users
tab in Task Manager
.
Client Name
JAN-PC shows where the connection originates from
You can also use CLI
to view current RDP sessions which can be run with no problems against remote machines.
C:\>query session /?
An example of query session output>>
Comprehensive info on managing remote desktop services from CLI.
When you login via Remote Desktop the current loggedin user is Switched Out.
For Windows 2000 and higher, you can view in the Task Manager. You can press Ctrl+Shift+Escape to bring it up, then click the Users tab. If you see 'Console' listed, they are logged in to the physical machine. If they show as Disconnected
, they are no longer actively on the system. If it shows something such as RDP-001
or a computer name, they are logged in via remote desktop