: :

Add Comment | Related Links | TrackBack
Related Content

Determine Whether User Connected Through Remote Desktop on the Command-Line

Using the Windows "qwinsta" command-line tool, you can determine whether your user account (or someone else's account if you have admin privileges) is currently actively connected to a Windows server through Remote Desktop. This method is handy for automated processing (batch scripts) or monitoring server state. I'm sure there are other uses for this ability, please share your ideas. Below are examples of connection status.

In this first example, the user is logged on and actively connected to the server through Remote Desktop. Note "rdp-tcp#744" under "SESSIONNAME" and "Active" under "STATE".

 SESSIONNAME       USERNAME                 ID  STATE   TYPE        DEVICE
>rdp-tcp#744 kansas 10 Active rdpwd

In this next example, the user is logged on to the server, but has disconnected the Remote Desktop. Noticed that the field under "SESSIONNAME" is empty and that the "STATE" shows "Disc", which stands for disconnected.

 SESSIONNAME       USERNAME                 ID  STATE   TYPE        DEVICE
> kansas 10 Disc rdpwd

In this third example, the user has connected once again through Remote Desktop. "qwinsta" shows a new "SESSIONNAME" and "STATE" is set back to "Active" again.

 SESSIONNAME       USERNAME                 ID  STATE   TYPE        DEVICE
>rdp-tcp#745 kansas 10 Active rdpwd

It'd be fairly simple to write a batch script that monitors this connection and determine whether the user logged on or connected. Once the script determined that much, it's fairly easy to perform an automated action based on that knowledge.

Chieh Cheng
Fri, 23 Apr 2010 19:08:26 +0000

Add Comment | Related Links | TrackBack
Related Content

Did your message disappear? Read the Forums FAQ.

Add Comment

Spam Control | * indicates required field
Your Name: *
Remember Me!
Comment: *
File attachment is optional. Please do not attach a file to your submission unless it is relevent.
Attach File:
(20 MB Max)
Spam Protection: * Answer of 8 + 7?
Click button only once, please!


TrackBack only accepted from WebSite-X Suite web sites. Do not submit TrackBacks from other sites.

Send Ping | TrackBack URL | Spam Control

No TrackBacks yet. TrackBack can be used to link this thread to your weblog, or link your weblog to this thread. In addition, TrackBack can be used as a form of remote commenting. Rather than posting the comment directly on this thread, you can posts it on your own weblog. Then have your weblog sends a TrackBack ping to the TrackBack URL, so that your post would show up here.

Messages, files, and images copyright by respective owners.

Articles | Wiki
Forums | Latest | RSS
Library | Links | News
Search | Store | Help

52 Users Online

Hacking Digital Cameras
Fun for Photographers

Amazon Associate

Copyright © 2004 - 2019. All Rights Reserved.