Ways to check if user is active on remote machine before RDP'ing

24

9

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.

YetAnotherUser

Posted 2011-07-21T18:14:15.693

Reputation: 752

@Darius & YetAnotherUser : I answered below: http://superuser.com/a/822743/430

– Kevin Worthington – 2014-10-08T20:13:14.723

2I would like to find out how to do exactly the same thing but in Win7 environment. – Darius – 2011-07-21T20:11:56.710

@Darius, just found the solution to this. Haven't tested it on W7 but hope this works for you as well. – YetAnotherUser – 2011-07-21T21:23:51.420

Answers

31

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

YetAnotherUser

Posted 2011-07-21T18:14:15.693

Reputation: 752

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 – 2011-07-21T21:53:09.003

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

Felix D.

Posted 2011-07-21T18:14:15.693

Reputation: 137

1Getting Access is denied from an elevated command prompt. I am also using a domain admin account. – Shiv – 2017-05-18T01:33:45.637

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 – 2018-04-04T09:35:37.263

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

Canadian Luke

Posted 2011-07-21T18:14:15.693

Reputation: 22 162

1I'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 – 2011-07-21T18:32:51.347

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

Linker3000

Posted 2011-07-21T18:14:15.693

Reputation: 25 670

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 – 2019-09-26T15:01:42.143

+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 – 2011-07-21T20:08:54.577

1

Another way:

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

(tested on Windows 7)

Kevin Worthington

Posted 2011-07-21T18:14:15.693

Reputation: 1 554

Out of curiosity, why when I try this I get "Access denied" error message? – Darius – 2014-10-08T21:51:10.510

You may not have administrator privileges on the remote computer. – Kevin Worthington – 2014-10-09T02:12:13.297

I"m a net admin, I think I should but you pointed me into the right direction.... – Darius – 2014-10-09T05:12:43.943

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 – 2017-06-27T19:45:16.230

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.

Norm

Posted 2011-07-21T18:14:15.693

Reputation: 1

16 years, but who's countng – mic84 – 2018-03-09T18:44:57.893