The TSDISCON command is used in Windows operating systems to disconnect a user from a Terminal Services session without closing it. This command is beneficial in situations where a session needs to be temporarily disconnected but can be resumed later without losing the current state. It’s commonly used in administrative tasks, server management, and by users who need to manage remote sessions effectively.


To use the TSDISCON command, follow the syntax below:

TSDISCON [sessionid | sessionname] [/SERVER:servername] [/V]
  • sessionid: Specifies the ID of the session to be disconnected.
  • sessionname: Specifies the name of the session to be disconnected.
  • /SERVER:servername: Connects to a specific server. If omitted, the command targets the local server.
  • /V: Displays information about the actions being performed.


  • sessionid/sessionname: Disconnect the session by specifying its ID or name. If no session is specified, the current session is disconnected.
  • /SERVER:servername: This option allows the command to be executed on a remote server, hence affecting a session on that server.
  • /V: This is a verbosity flag that, when used, provides detailed output of the command’s operations, helping in troubleshooting and confirming actions.


  1. Disconnect the Current Session:


    This command disconnects the user from the current session.

  2. Disconnect a Specific Session by ID:


    This would disconnect the session with ID 2.

  3. Disconnect a Session on a Remote Server:

    TSDISCON 3 /SERVER:Server01

    Disconnects the session with ID 3 on the server named “Server01”.

  4. Verbose Output:


    Disconnects the session with ID 3 and displays detailed information about the actions performed.

Common Issues

  • Permission Errors: Users might encounter permission issues if they attempt to disconnect other users’ sessions without adequate privileges. Ensure you have the right administrative rights or permissions.
  • Session Identification: Incorrect session ID or name might lead to errors. Always verify the current sessions with the QUERY SESSION command before attempting to disconnect.


TSDISCON can be used in scripts and batch files to manage user sessions programmatically. It’s often paired with commands like QUERY SESSION to fetch session IDs and then conditionally disconnect them based on activity or time limits.

Example script to disconnect idle sessions:

FOR /F "skip=1 tokens=3,4" %%i IN ('query session') DO (
    IF %%j EQU Disc (
        tsdiscon %%i

This script checks for disconnected sessions and logs them off to free up resources.

  • QUERY SESSION: List sessions.
  • LOGOFF: Ends a session.
  • RWINSTA/RESET SESSION: Reset the session subsystem hardware and software to known initial values.

For more details and further reading, the official Windows Command Line documentation provides comprehensive guides and updated information.