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

Julien Nephtali picture Julien Nephtali · Feb 18, 2009 · Viewed 14.6k times · Source

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?

Answer

Oskar Duveborn picture Oskar Duveborn · Feb 18, 2009

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...