Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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.

share|improve this question
2  
"I would ultimatly prefer a programmatic answer" - Then you're in the wrong place and StackOverflow would be better suited to requests for code. –  Karan Jan 6 '13 at 1:50
1  
@Karan I originally thought so too, but I think this could be of use to any windows power user. –  chollida Jan 6 '13 at 2:40
    
One you have this information what are you doing with it, it affects what you can do as a solution (if the question is "I want to know if the computer I just walked up to is in a terminal session" the answer could be as simple as "Move your mouse to the top middle of the screen and a bar to close the remote desktop session shows up") –  Scott Chamberlain Jan 6 '13 at 3:06
    
Also as is your question would be closed on SO for being overly broad and vauge. Are you wanting to check your user? Are you wanting to see if users on a server are connected via the console or via RDP? Is the app being run on a computer with Wtsapi32.dll (only server editions have it) –  Scott Chamberlain Jan 6 '13 at 3:10

4 Answers 4

up vote 1 down vote accepted

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
share|improve this answer
    
Hm, my solution assumes the windows executable query.exe is on your path. On one of my win7 boxes query.exe is available in c:\windows\system32, but on another it is nowhere to be found. Not sure what windows component brings query.exe in. –  user319027 Apr 28 at 19:51

When you login via Remote Desktop the current loggedin user is Switched Out.

share|improve this answer
2  
that depends on the setup man ... –  WeloSefer Jan 6 '13 at 3:05
    
If multi user remote desktop is setup then you won't get kicked. On a standard consumer PC setup you will be kicked to the lock screen and says "Login in from RANDOM-PC". –  Sam Jan 6 '13 at 6:44

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

share|improve this answer

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

enter image description here

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>>

enter image description here

Comprehensive info on managing remote desktop services from CLI.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.