Tuesday, 21 July 2015

How to Logoff Remote Desktop User via Command Line

We can logoff a remote desktop user session by using the command line tool Logoff.

Logoff command syntax:

LOGOFF [sessionname | sessionid] [/SERVER:servername] [/V] [/VM]

  sessionname         The name of the session.
  sessionid           The ID of the session.
  /SERVER:servername  Specifies the Remote Desktop server containing the user session to log off.
  /V                  Displays information about the actions performed.
  /VM                 Logs off a session on server or within virtual machine.
Before proceed, we should find the ID of the session which we want to terminate, we can list all the remote desktop user sessions by using the command QWinsta.
QWinsta /server:[Server name or IP]
Replace the parameter [Server name or IP] with the name or IP address of the Remote Computer. You will get the list of remote user sessions with username and session ids in the command window.
How to Logoff Remote Desktop User via Command Line

From the above output you can easily find the session id of an user whom you want to logoff. Now, I am trying to terminate the user Administrator and its session id is 1.

Command to logoff remote user:

Logoff /SERVER:[Server name or IP] [Session ID] /V 
Logoff /SERVER: 1 /V 

Command to disconnect remote user:

You can also use the following command if you want only disconnect the remote user session instead of complete logoff.
RWinsta /server:[Server name or IP] [Session ID]
RWinsta /server: 1
Finally, use the command QWinsta to confirm the user is logged out/disconnected successfully.
QWinsta /server:


No comments:

Post a Comment