logoff remote desktop sessions via command line tools
This trick I learned from my one of ex-college. In Windows servers, only two remote desktop sessions allowed with administrative access. There are situations, you can’t connect to the server via remote desktop because of two sessions already active. You may have seen this dialog box. ("Remote Desktop Disconnected", "This computer can’t connect to the remote computer")

Usually Windows Administrators, open "Terminal Services Manager" (in Administrative tools), connect to the problematic server and log off the unwanted sessions. There are easy ways if you love command line based tools.
Query the Remote Server for Current Terminal Sessions
To query and list the sessions on the remote session, you could use QUser.exe or QWinsta
1. QUser
QUser command comes with all the latest Windows clients and servers. This will list the sessions of the remote server (or local machine).
NOTE: if you are using Windows XP, you need to add this location into your System path: C:WindowsSystem32DLLCache. To do this, in command prompt, type the following.
SET PATH = %PATH%;C:WindowsSystem32DLLCache;
QUser help shows,
C:Anand>QUser /?
Display information about users logged on to the system.QUERY USER [username | sessionname | sessionid] [/SERVER:servername]
username Identifies the username.
sessionname Identifies the session named sessionname.
sessionid Identifies the session with ID sessionid.
/SERVER:servername The server to be queried (default is current).
E.g.,
C:>quser /server:MyCitrixSVR
USERNAME SESSIONNAME ID STATE IDLE TIME LOGON TIME
johndoe ica-tcp#966 10 Active 7 7/31/2008 3:04 PM
averagejoe ica-tcp#969 1 Active 9 7/31/2008 3:30 PM
familyman ica-tcp#984 5 Active 1:06 7/31/2008 4:33 PM
normaldude ica-tcp#987 2 Active 4 7/31/2008 6:20 PM
2. QWinsta
QWinsta is little different and better. It has more features and options. It comes with all flavors of Windows. QWinsta command line help displays as,
C:>qwinsta /?
Display information about Terminal Sessions.QUERY SESSION [sessionname | username | sessionid]
[/SERVER:servername] [/MODE] [/FLOW] [/CONNECT] [/COUNTER]sessionname Identifies the session named sessionname.
username Identifies the session with user username.
sessionid Identifies the session with ID sessionid.
/SERVER:servername The server to be queried (default is current).
/MODE Display current line settings.
/FLOW Display current flow control settings.
/CONNECT Display current connect settings.
/COUNTER Display current Terminal Services counters information.
E.g.,
C:>qwinsta /server:citrixserver
SESSIONNAME USERNAME ID STATE TYPE DEVICE
0 Disc rdpwd
ica-tcp 65536 Listen wdica
rdp-tcp 65537 Listen rdpwd
console 16 Conn wdcon
ica-tcp#966 johndoe 10 Active wdica
ica-tcp#969 apple 1 Active wdica
ica-tcp#984 averagejoe 5 Active wdica
ica-tcp#987 familyman 2 Active wdica
ica-tcp#989 whoisme 3 Active wdica
You are welcome to try the other options QWinsta provides.
Logoff the Remote Sessions
To Log off the terminal session of the remote server, you can use any one of two command line tools. One of LOGOFF and another one is RWINSTA. Before you log off the remote session, you should know the "Session ID" which you get it from "QUSER" OR "QWINSTA" commands as above stated.
1. Logoff
Logoff command kicks off (logging off) the specified remote session. Log off help shows,
C:>logoff /?
Terminates a session.LOGOFF [sessionname | sessionid] [/SERVER:servername] [/V]
sessionname The name of the session.
sessionid The ID of the session.
/SERVER:servername Specifies the Terminal server containing the user
session to log off (default is current).
/V Displays information about the actions performed.
E.g.,
C:>logoff /server:infra-apps 1 /v
Logging off session ID 1
2. RWinsta
RWinsta has same parameters and does same thing as log off command. It simply means Reset WINdows STAtion. The help goes as,
C:>RWinsta /?
Reset the session subsytem hardware and software to known initial values.RESET SESSION {sessionname | sessionid} [/SERVER:servername] [/V]
sessionname Identifies the session with name sessionname.
sessionid Identifies the session with ID sessionid.
/SERVER:servername The server containing the session (default is current).
/V Display additional information.
E.g.,
C:>RWinsta /Server:MyWinServer 1
Note: RWinsta command does not return anything.
Happy Re-setting the remote sessions (Hey, stop cursing your co-workers who didn’t log off their sessions).
logoff remote desktop sessions via command line tools的更多相关文章
- [RabbitMQ]Windows环境下rabbitmqclt(Command Line Tools)出现Erlang distribution failed错误的解决方法
摘要 当使用rabbitmqctl时出现Erlang distribution failed,把%SystemRoot%Windows\System32\config\systemprofile下的. ...
- xcode5下面安装Command Line Tools
运行命令 sudo xcode-select --install 就会显示一行文字,并且弹出一个对话框,确认安装后他就会自己下载来安装了. 至此,Command Line Tools就能够重新复活了
- MAC 命令行工具(Command Line Tools)安装
不过升级后安装命令行工具(Command Line Tools)时发现官网没有clt的下载安装包了,原来改了,使用命令在线安装. 打开终端,输入命令:xcode-select --install 选择 ...
- Mac appium.dmg. Xcode Command Line Tools
You need to install the command line tools as marked in your message: ✖ Xcode Command Line Tools are ...
- appium----【已解决】【Mac】环境配置提示“Xcode Command Line Tools are NOT installed!"
报错问题提示截图如下: 报错原因 :根据给出的信息很明显可以看到是"Xcode Command Line Tools"此工具没有安装 解决措施: 打开终端直接执行:xcode-se ...
- Xcode 8.X Command Line Tools
Summary Step 1. Upgrade Your System to macOS Sierra Step 2. Open the Terminal Application Step 3. Is ...
- Xcode command line tools
1.Xcode command line tools 安装 如果你不是一名 iOS 或 OS X 开发者,可以跳过安装 XCode 的过程,直接安装 Xcode command line tools. ...
- the command line tools
PhpStorm 10.0.2 http://stackoverflow.com/questions/22572861/error-cant-use-subversion-command-line-c ...
- stderr: xcode-select: error: tool 'xcodebuild' requires Xcode, but active developer directory '/Library/Developer/CommandLineTools' is a command line tools instance
错误提示: (1). stderr: xcode-select: error: tool 'xcodebuild' requires Xcode, but active developer direc ...
随机推荐
- Python全栈开发【基础一】
Python全栈开发[第一篇] 本节内容: Python 的种类 Python 的环境 Python 入门(解释器.编码.变量.input输入.if流程控制与缩进.while循环) if流程控制与wh ...
- JVM内存管理------垃圾搜集器参数精解
本文是GC相关的最后一篇,这次LZ只是罗列一下hotspot JVM中垃圾搜集器相关的重点参数,以及各个参数的解释.废话不多说,这就开始. 垃圾搜集器文章传送门 JVM内存管理------JAVA语言 ...
- 【目录】python
python 入门学习(一) 入门学习(二) 入门学习(三) 入门学习(四) 入门学习(五) 入门学习(六) 入门学习(七) 入门学习(八) 入门学习(九) 入门学习(十) Head First Py ...
- 使用微信web开发者工具调试微信企业号页面(前端页面,已发布在服务器上的)
前几天写了一篇使用fiddler调试微信端页面的,然后博友评论说使用fiddler太麻烦了,推荐使用微信web开发者工具调试微信页面,这两天弄着玩了一下,很强大.这篇文章只是做一个记录,方便自己以后使 ...
- 由一段字符串中查找URL引出——正则表达式
需求很简单,是从一段文本中匹配出其中的超链接.基本的做法就是用正则表达式去匹配.但是有这样一个问题. 网上大部分的识别URL的正则表达式url末尾有空格的情况下可以正确识别.比如这样的情况: &quo ...
- javaScript的call关键字
function add(a, b) { alert(a + b); } function sub(a, b) { alert(a - b); } add.call(sub,3,1); //这个例子中 ...
- Jetty使用教程(四:23)—Jetty开发指南
二十三.Maven和Jetty 这一章节将说明如何通过Maven管理Jetty和使用Jetty的Maven插件. 23.1 使用Maven Apache Maven是一个款软件项目管理工具.基于项目对 ...
- C#对象序列化与反序列化
C#对象序列化与反序列化(转载自:http://www.cnblogs.com/LiZhiW/p/3622365.html) 1. 对象序列化的介绍.......................... ...
- 互联网+下PDA移动智能手持POS超市收银开单软件
是一套专为中小超市.专卖店设计的收银管理软件,广泛应用于中小超市(百货商店).化妆品店.婴幼儿用品店.玩具店.保健品店.茶叶店. 电器.文具图书.手机通讯器材店等行业的中小型店面店铺.该系统具有完善的 ...
- Python lambda函数
python允许定义单行的小函数,定义lambda函数的形式如下: lambda 参数:表达式lambda函数默认返回表达式的值,可接收任意个参数,包括可选参数,但是表达式只有一个.