36

We have a common Windows XP machine that's shared between multiple users. All of them use a common domain login to rdp into it. Now the problem is, we some times end up taking over other persons active session without either party being warned (no warning is issued as we use same login).

Is there a way to test if the current logged in user on remote machine is active (terminal locked?) or not?

We can not use VNC or LogMeIn or other desktop sharing utilities for security reasons (blocked by IT).

I'm ok developing some quick test utility (C#,C++,scripting etc) as well.

Edit:

  1. As we are using same login - users are not logging out, they just disconnect or lock the terminal.
3
  • 2
    I would like to find out how to do exactly the same thing but in Win7 environment.
    – Darius
    Jul 21, 2011 at 20:11
  • @Darius, just found the solution to this. Haven't tested it on W7 but hope this works for you as well. Jul 21, 2011 at 21:23
  • @Darius & YetAnotherUser : I answered below: superuser.com/a/822743/430 Oct 8, 2014 at 20:13

6 Answers 6

38

We can use qwinsta to Query WINdows STAtion and get a list of all active sessions.

State column shows if a user is active or not. This do require admin access on the target machine.

Got it on TechTalkz: How to View / Disconnect Remote Desktop Sessions from Commandline

enter image description here

1
  • 1
    +1 That's handy. I've been trying to figure out what I have used in the past, but I could not figure it out. I think it may have been psexec \\COMPUTERNAME net session. You can also use tsdiscon to disconnect.
    – paradroid
    Jul 21, 2011 at 21:53
3

Similar to the accepted answer you can also use Query.exe like this:

quser /server:<COMPUTERNAME>

This will result ins the following:

enter image description here

3
  • 1
    Getting Access is denied from an elevated command prompt. I am also using a domain admin account.
    – Shiv
    May 18, 2017 at 1:33
  • Worked fine for me checking if me RDP-ing would boot someone off a Win 2k8 R2 server. Status was "Disc" (disconnected), so I can RDP in safely.
    – Adambean
    Apr 4, 2018 at 9:35
  • 1
    Microsoft documentation on query user is here (quser is a shortcut for that.) It returns this info: Name of the user Name of the session on the Remote Desktop Session Host server Session ID State of the session (active or disconnected) Idle time (the number of minutes since the last keystroke or mouse movement at the session) Date and time the user logged on
    – Tim Bailen
    Feb 5, 2021 at 19:02
1

You could use the NET SEND command to send a message to the machine to see if anyone's on it. This can be made easier by using a GUI app - the link below is the first free one I found by doing a Web search so it comes without any specific endorsement.

http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/net_send.mspx

http://www.fomine.com/netsend.html

2
  • +1 - Net Send is a good option. It does requires other user to respond to confirm s/he is using the machine, and one would unnecessarily have to wait 4-5 mins before assuming it's not being used. More over it requires Messenger service to be running on all systems, which is not true in our case. Jul 21, 2011 at 20:08
  • It should be noted, that NET SEND was a correct answer for the question as asked, refrring to Windows XP, but is not anymore for current versions of Windows, as SEND has been removed from NET for blatant abuse issues. Sep 26, 2019 at 15:01
1

Another way:

wmic.exe /node:<computername or IP address> computersystem get username

(tested on Windows 7)

4
  • Out of curiosity, why when I try this I get "Access denied" error message?
    – Darius
    Oct 8, 2014 at 21:51
  • You may not have administrator privileges on the remote computer. Oct 9, 2014 at 2:12
  • I"m a net admin, I think I should but you pointed me into the right direction....
    – Darius
    Oct 9, 2014 at 5:12
  • This is the only answer listed that gave the option to specify what user to connect to the remote machine as. The others appear to only work if you are in the same domain and running as the user with access.
    – LeBleu
    Jun 27, 2017 at 19:45
0

Create a BAT file the generates a file on a share saying the computer is in use. When a user logs in, it runs and creates that file. When a user logs out (can be done by GP script), it deletes the file. Check the share for that file before connecting

1
  • 1
    I'm sorry I should have mentioned that - As we are using same login - users are not logging out, they just disconnect or lock the terminal. Jul 21, 2011 at 18:32
0

Just as an FYI, I know this is over a year old, but even if someone has domain administrator rights, there are GPO policies that could block certain admin accounts (domain, enterprise, etc) from logging in remotely to a machine.

This is to help protect machines that are a part of a remote location from being administered remotely by someone higher up in the AD structure.

You can check to see if it's being denied by looking through your GPO reports for the local machine under the

                  gpreport /h report.html

from an administrative command prompt.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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