Windows: Howto terminate a RDP Session remotely by command line

Hi,

when a RDP sessions hangs there are multiple ways to destroy it. The command line way:

Identify the RDP Session ID. Use quser


C:\>quser /Server:YourWindowsServer
 USERNAME              SESSIONNAME        ID  STATE   IDLE TIME  LOGON TIME
 winuser               rdp-tcp#6           2  Active          3  24.09.2014 22:26


or qwinsta


C:\>qwinsta.exe /server:YourWindowsServer
 SESSIONNAME       USERNAME                 ID  STATE   TYPE        DEVICE
 services                                    0  Disc
 console                                     1  Conn
 rdp-tcp#7         winuser                   2  Active
 rdp-tcp                                 65536  Listen

and terminate the session with logoff

C:\>logoff rdp-tcp#6 /server:YourWindowsServer

or reset the session with RWinsta

C:\>RWinsta rdp-tcp#6 /server:YourWindowsServer

Michael

Leave a Reply