Kick user off remote Desktop session

  • Avijit Dutta
    • Jul 25, 2019
    • 2 min read

How to Logoff/Kill Remote Desktop Sessions?

Updated: Aug 29, 2020

Article No :: KB00007



In the Windows Servers, by default, there are only two remote desktop sessions allowed [until you have taken an RDP license]. In multiple situations, you find that you cant connect/login into the server via RDP/MSTSC because two sessions are already active or in disconnected mode. You get the error msg "Remote Desktop Disconnected", "This computer cant connect to the remote computer."



Permission/Access required - You must be the part of the local administrator group of the remote server to kill/reset the disconnected or active sessions.


Applies to - Windows Server 2016, Windows Server 2012 R2, Windows Server 2012, Windows Server 2008 R2, Windows Server 2008




Query the Remote Server for Current Terminal Sessions


QWinSta - Displays information about sessions on a Remote Desktop Session Host [RD Session Host] server


First, we query to list the sessions on the remote server.


Command for Query the Server Sessions is

qwinsta /server:[ServerIP/Hostname]


Example:

qwinsta /server:192.168.40.1

qwinsta /server:myServer.Contoso.com or myserver.contoso.local


Output of Command

C:>qwinsta /server:myServer.contoso.com

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 avijitd 10 Active wdica

ica-tcp#969 deepakk 1 Active wdica


Note: Please take a note of the session ID from the Query command. In the above example, if i have to disconnect the session of User "avijitd" then the session id is "10".




Logoff/Kill the Remote Desktop Sessions


RWinSta - Enables you to reset [delete] a session on a Remote Desktop Session Host [rd Session Host] server.


Command for Release the Server Sessions

rwinsta [Session ID] /server:[Server IP]


Example: We will kill/logoff the remote session of user "avijitd" whose session ID is "10"

rwinsta 10 /server:192.168.40.1

rwinsta 10 /server:myServer.Contoso.com or myserver.contoso.local


Note: RWinsta command does not return anything.



Some good books related to Windows Hacks and Microsoft Azure Cloud. Do check it out.




#KillRemoteSession #RemoteDesktopSession #QWinSta #RWinSta #LogoffRemoteSession #WindowsServer #RDPSession #MSTSCSession #Server

  • Remote Desktop Sessions
  • Kill Sessions
  • Remote Logoff
  • KillRemoteSession
  • Kill Remote Session
  • QWinSta
  • RWinSta
  • LogoffRemoteSession
  • RDPSession
  • MSTSCSession
  • Kill MSTSC Session
  • Kill RDP Session
  • Tip of the Day
0 views0 comments
Post not marked as liked

Article No :: KB00007



In the Windows Servers, by default, there are only two remote desktop sessions allowed [until you have taken an RDP license]. In multiple situations, you find that you cant connect/login into the server via RDP/MSTSC because two sessions are already active or in disconnected mode. You get the error msg "Remote Desktop Disconnected", "This computer cant connect to the remote computer."



Permission/Access required - You must be the part of the local administrator group of the remote server to kill/reset the disconnected or active sessions.


Applies to - Windows Server 2016, Windows Server 2012 R2, Windows Server 2012, Windows Server 2008 R2, Windows Server 2008




Query the Remote Server for Current Terminal Sessions


QWinSta - Displays information about sessions on a Remote Desktop Session Host [RD Session Host] server


First, we query to list the sessions on the remote server.


Command for Query the Server Sessions is

qwinsta /server:[ServerIP/Hostname]


Example:

qwinsta /server:192.168.40.1

qwinsta /server:myServer.Contoso.com or myserver.contoso.local


Output of Command

C:>qwinsta /server:myServer.contoso.com

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 avijitd 10 Active wdica

ica-tcp#969 deepakk 1 Active wdica


Note: Please take a note of the session ID from the Query command. In the above example, if i have to disconnect the session of User "avijitd" then the session id is "10".




Logoff/Kill the Remote Desktop Sessions


RWinSta - Enables you to reset [delete] a session on a Remote Desktop Session Host [rd Session Host] server.


Command for Release the Server Sessions

rwinsta [Session ID] /server:[Server IP]


Example: We will kill/logoff the remote session of user "avijitd" whose session ID is "10"

rwinsta 10 /server:192.168.40.1

rwinsta 10 /server:myServer.Contoso.com or myserver.contoso.local


Note: RWinsta command does not return anything.



Some good books related to Windows Hacks and Microsoft Azure Cloud. Do check it out.




#KillRemoteSession #RemoteDesktopSession #QWinSta #RWinSta #LogoffRemoteSession #WindowsServer #RDPSession #MSTSCSession #Server

Video liên quan

Chủ Đề