How to identify users which are connected to a windows server via remote desktop
Asked Answered
S

6

5

At my workplace, we have lab machines that we use to do our testing.

The standard procedure to reserve a machine for testing was to walk around the office to make sure that no one was using the machine.

This is highly inefficient and time consuming.

At first, I set up a web page where people could reserve the lab machine but nobody was keeping the page updated so that turned up to be useless.

I finally found a solution using Microsoft log parser and wanted to share it to the stack overflow community.

It is a batch file that runs on the machine so the user can identify the last users that use the machine and easily IM them to ask if the machine is free.

Is there a better solution to do this?

Seizing answered 18/2, 2009 at 21:31 Comment(5)
you asked a question then answered it 2 min later.... are you blogging?Conceptacle
This is actually considered acceptable by the site creators. I think the question should have been more questiony, but asking a question solely to answer it yourself is perfectly fine.Coggins
I don't even think it needs to be a wiki. It isn't a poll and it is not SO meta discussion.Coggins
I have no objections to this sort of thing. He had a programming problem, solved it himself, and decided to share. If I had any more votes today I'd vote him up.Armlet
@bthb: I thought it was weird too. In fact, I suspected that the OP might have been gaming the site (i.e. asking a question, then logging in with another account to answer the question and collect rep), but botched it midway. However, I think EBGreen is correct :)Schaeffer
M
8

Use the built-in command qwinsta (Query Win Station) to figure out what sessions (including console) are active or inactive (disconnected) and then act on the given information (creds to krusty.ar btw for linking this already).

If you feel people are abusing the machine in question, refer to rwinsta to nuke their sessions into oblivion...

Multivocal answered 18/2, 2009 at 22:20 Comment(0)
S
2

You will need to install the Microsoft Log Parser

Then create the following 2 files

TSLoginsDetails.sql

SELECT 
      timegenerated, 
      EXTRACT_TOKEN(Strings,1,'|') AS Domain, 
      EXTRACT_TOKEN(Strings,0,'|') AS User, 
      EXTRACT_TOKEN(Strings,3,'|') AS SessionName,
      EXTRACT_TOKEN(Strings,4,'|') AS ClientName,
      EXTRACT_TOKEN(Strings,5,'|') AS ClientAddress,
      EventID
FROM Security 
WHERE EventID=682 
ORDER BY timegenerated DESC

TSLogins.bat

echo off
cls
c:
cd "c:\Program Files\Log Parser 2.2\"
logparser.exe file:TSLoginsDetails.sql -o:DATAGRID

Now by placing this batch file on the desktop, the user can see who were the last people to login and contact them by IM to verify if they are done.

Seizing answered 18/2, 2009 at 21:33 Comment(7)
Expand it so when you log in, if it isn't the current user who logged in last, set an alert to contact the correct person. (Start IM, prefill email, use some other notification protocol.) If it was the current user, do nothing.Gemination
Doesn't this require that the person running the batch file have already logged in to the machine in question; in other words, possibly already broken into the other user's session?Euh
Why don't you have your users log in to these lab machines with their own user accounts? Then when someone else tries to log in, Windows will just tell you that another session is currently active, and it will tell you who is logged in.Euh
bslorence We log in console. We dont have a domain set up in our workplace. Its not considered harmful if you cut-off someone's session just as long as you dont stop a load test someone else started.Seizing
I see. Are you running the s/w you develop on these lab machines or are they just test clients for servers running separately? I'm just asking because it sounds like you might also all be logging in with admin privileges to the test machines.Euh
Separate thought, sort of: can you change "FROM Security" in your query to "FROM \\remotemachine\Security" to allow developers to run this from their own machines? Credentials might be a problem if you don't have Active Directory.Euh
... I guess that also wouldn't work if your developers aren't running Windows at their desks. ;-)Euh
G
1

How about posting the information from the log file to the website that tells who is currently using the machine as well.

  1. Check and notify when they log in.
  2. Updated the "who is using the machine" page you made prior.
  3. Run a AT job that checks every couple of hours who is on it.
Gemination answered 18/2, 2009 at 21:40 Comment(0)
R
1

Totally out of the box:

You can install the Software Testing Automation Framework (STAF) on your servers and desktops to manage your tests. It's written in Java, so you can use it on Windows and Unix/Linux desktops and servers.

Using STAF, you can create a resource pool of test servers on which you conduct tests, then write STAX jobs (STAX is a STAF execution framework) to conduct the tests. The job can grab the first available server from the resource pool, run the test, monitor the test status, log results, notify the submitter, then release the server back into the pool when done. If you have multiple people submitting jobs for tests, STAF will manage the queue of requests and satisfy them as they came in. Users can either monitor the job from their desktop, or you can set up email alerts to notify them when the test is complete.

Rizzo answered 18/2, 2009 at 23:51 Comment(0)
T
0

I'm not sure if I understand you, but there are a set of command line tools to deal with terminal server sessions, and there's also a Windows API to do the same if you need to do this from a program.

Tymes answered 18/2, 2009 at 22:8 Comment(0)
D
0

Since it sounds like you're a microsoft shop, you can set up the machines as resources in outlook/exchange and reserve them that way.

Dominican answered 18/2, 2009 at 22:13 Comment(1)
I think the issue is more a matter of compliance. The OP already had a scheduling system in place but it was not used.Coggins

© 2022 - 2024 — McMap. All rights reserved.