Determine Whether User Connected Through Remote Desktop on the Command-LineUsing 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 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 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 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
Did your message disappear? Read the Forums FAQ. Add Comment
TrackBackTrackBack only accepted from WebSite-X Suite web sites. Do not submit TrackBacks from other sites.
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
169 Users Online
![]() |
Copyright © 2004 - 2025. All Rights Reserved. |