How to find out who is currently logged on via VNC

0

We have a Windows XP Pro machine at work that several people connect to via VNC (RealVNC). Each user logs into Windows under their own account. We all want to be polite to the other users and only connect when nobody else is using the machine. If someone else is using it I want to find out who (ie. what Windows user is logged on) so I can ask them when they're likely to finish. The question is: how do I find this out?

What we currently do is first try to connect via RDP, so that it prompts us "User SmithJ is currently logged on. Do you want to log them off?" We answer "No", but now we know it's John Smith that's using it. This works, but it's a fair bit of extra hassle - you have to run Remote Desktop, select the machine, enter your password. Is there any way we can do this with VNC itself?

Of course, another way would be to send CtrlAlt-Del once connected via VNC, but that would be really annoying to the other person using it and I don't want to interrupt them like this.

Before someone asks, no, we cannot just use RDP - the session must appear to be the "interactive" session. However, if there are alternative products to VNC that can do this I'd be interested to hear about them.

EMP

Posted 2010-07-12T04:30:24.443

Reputation: 4 688

Answers

1

Following on from:

echo %USERNAME% > CurrentlyLoggedIn.txt

It looks like windows XP, and later, have an environment variable "SESSIONNAME", which is set to "Console" for the console login session.

I'm not sure what its set to for an RDP (remote desktop) session. If different, you can use that in the batch file as a means of qualifying if the magic file should be updated or not.

A little gotcha with this approach: You need a means of deleting that file on console logout as well.

quickly_now

Posted 2010-07-12T04:30:24.443

Reputation: 1 797

Hmm, you could be on to something here! I'm not sure if this is enough to solve the problem, but +1. – EMP – 2010-10-30T23:11:35.677

0

Sounds like using psloggedon.exe from Sysinternals would be your best bet. Just run a simple batch file or something like that and it will tell you who is logged on the remote pc. If you have multiple users via RDP and Console try using net sessions \\computer and that will return all the RDP sessions on that remote computer.

David Remy

Posted 2010-07-12T04:30:24.443

Reputation: 1 899

Nice idea, but it shows me two users logged on "locally" and I don't know which of them is the interactive user and which has a remote desktop session. – EMP – 2010-07-12T04:36:49.840

Getting tired and I can't think of it, but use psexec to execute the command I can't remember (here is where the time of night kicks in) to find the logged in session numbers, that should do it for you. I'll try to check again in the morning and see if I remember the way to do this. – David Remy – 2010-07-12T05:00:36.163

0

you could telnet to the other machine or use psexec, and execute a command

Could execute a script that does netstat -aon on the server, and looks at the IP and. then has another file with IPs and usernames one per line. find the line with that IP and it displays the line showing the username.

or

Each Client, could use psexec to write a file on C:\ that says their name in it.

To find out who is using the computer, when it is in use, you can run a script that displays what is in that file.

barlop

Posted 2010-07-12T04:30:24.443

Reputation: 18 677

Sorry, but I don't think either of those are good solutions. Windows already knows who is logged on and I just need to ask it somehow. – EMP – 2010-07-12T23:06:20.023

in that case, you want to remotely execute this on the machine, and you'll see who the user is. C:>echo %USERPROFILE% <ENTER> then it will display something like C:\Documents and Settings\Charlie – barlop – 2010-07-13T14:03:53.030

Hmm.. my echo %userprofile% won't work, because psexec only logs on as whichever user it logs on as, which is either the same user that is currently on on the local machine, or the user/pass you specify to be used on the remote machine. – barlop – 2010-07-13T22:13:09.193

Trying to understand your question.."we cannot just use RDP - the session must appear to be the 'interactive' session." Would an "interactive session" be defined as connecting remotely not directly? How can you have session with RDP that doesn't appear to be interactive. Wouldn't VNC sessions and RDP sessions both be interactive and appear as such? – barlop – 2010-07-13T22:52:03.280

Also, with psloggedon, it gives times.. so if it shows two, then would perhaps the earlier time be the locally logged on session, and the interactive session be the later one? – barlop – 2010-07-13T23:01:11.433

And regarding psloggedon showing 2 users, and you not knowing which is local and which is interactive. For all you know, they could both be local. 'cos I think it just shows accounts that are in an active logged on state. You have this when "fast user switching" is enabled. If you disable that, then I think you'll find that only one username will be listed. If you want to know whether that user is interactive or not.. Then you can do psexec \thatcomp netstat -aon And then look to see if port 3389/remote desktop is established. Or port 590x/VNC is established. Then you know. – barlop – 2010-07-13T23:40:19.903

We don't have Fast User Switching enabled, so in this case there should only be one "interactive" session. By that I mean the one that appears as "Console" in Terminal Services Manager - the one that is displayed on the monitor plugged into the machine. – EMP – 2010-07-15T00:37:11.350

VNCing then clicking start twice would perhaps be an alternative to ctrl-alt-delete. At the top of the start menu it says the username.

You could have each user's wallpaper display their username.

Also, and more interestingly, regarding you having 2 users logged on according to psloggedon, why is that? I only get one. You said you are only using RDP to check which user it is. then clicking no.I tried that and it didn't affect the results on psloggedon.+anyhow,when I do log on with RDP,it only shows 1 user logged on under"local"(the user it says recently uses shared resources isn't relevant) – barlop – 2010-07-16T03:04:53.483

0

This may sound a little ghetto but it would work: You can add a batch script to everyones startup folder that does something like this-

echo %USERNAME% > CurrentlyLoggedIn.txt

then share that file on the machine and just create a shortcut to it from your machine. That way, when someone logs in they would automatically update that file, and if you ever needed to know who was logged in you would just double click the shortcut on your desktop to see.

user53654

Posted 2010-07-12T04:30:24.443

Reputation: 183

Yes, but that would run whether they are logged on locally or remotely, wouldn't it? – EMP – 2010-10-27T05:31:32.497