31

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.
  • 2
    I would like to find out how to do exactly the same thing but in Win7 environment. – Darius Jul 21 '11 at 20:11
  • @Darius, just found the solution to this. Haven't tested it on W7 but hope this works for you as well. – YetAnotherUser Jul 21 '11 at 21:23
  • @Darius & YetAnotherUser : I answered below: superuser.com/a/822743/430 – Kevin Worthington Oct 8 '14 at 20:13
36

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

| improve this answer | |
  • 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 '11 at 21:53
2

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

| improve this answer | |
  • 1
    Getting Access is denied from an elevated command prompt. I am also using a domain admin account. – Shiv May 18 '17 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 '18 at 9:35
1

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

| improve this answer | |
  • 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. – YetAnotherUser Jul 21 '11 at 18:32
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

| improve this answer | |
  • +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. – YetAnotherUser Jul 21 '11 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. – I'm with Monica Sep 26 '19 at 15:01
1

Another way:

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

(tested on Windows 7)

| improve this answer | |
  • Out of curiosity, why when I try this I get "Access denied" error message? – Darius Oct 8 '14 at 21:51
  • You may not have administrator privileges on the remote computer. – Kevin Worthington Oct 9 '14 at 2:12
  • I"m a net admin, I think I should but you pointed me into the right direction.... – Darius Oct 9 '14 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 '17 at 19:45
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.

| improve this answer | |
  • 1
    6 years, but who's countng – mic84 Mar 9 '18 at 18:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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