Reset Session - CMD


Overview

The Reset Session command in Windows CMD is used to reset a session of a remote desktop, terminal server, or any client session. Its primary purpose is to reinitialize a session’s environment settings to their original state, which can help resolve issues related to application stability, performance, or security. This command is particularly useful in administrative scenarios for managing multiple user sessions on a server.

Syntax

The basic syntax for using Reset Session is as follows:

reset session {SessionName | SessionID} [/server:ServerName] [/v]
  • SessionName : Specify the name of the session to reset.
  • SessionID : Use the session ID as an alternative to the session name.
  • /server:ServerName : Optional. Specifies the terminal server containing the session (default is the current server).
  • /v : Optional. Displays information about the actions being performed.

Options/Flags

  • /server:ServerName
    • Use to specify a remote server. If not provided, the command targets the server on which it is executed.
  • /v
    • Stands for “verbose.” When used, the command provides additional information about the process of resetting the session. It’s useful for troubleshooting or confirmation.

Examples

  1. Resetting a Session by Name

    reset session "Session1" /v
    

    This command resets the session named “Session1” on the local server and displays detailed information about the operation.

  2. Resetting a Session by ID on a Remote Server

    reset session 234 /server:Server02 /v
    

    Resets the session with ID 234 on “Server02” and shows verbose output.

Common Issues

  • Permission Errors: If you encounter permission-related errors, ensure you are running CMD as an administrator.
  • Invalid Session Identification: Mistyping the session name or ID can lead to an “Invalid session name” error. Always verify the session identifiers before running the command.
  • Network Issues: When using the /server option, network issues can prevent the command from reaching the target server. Ensure network connectivity and server availability.

Integration

The Reset Session command can be integrated with other CMD commands for more complex workflows. For example, you can use a script to query all sessions and selectively reset those that meet certain criteria.

for /f "tokens=1,2 delims= " %%i in ('qwinsta /server:Server01') do (
    if %%j equ "DISCONNECTED" (
        reset session %%i /server:Server01 /v
    )
)

This script checks for disconnected sessions on “Server01” and resets them.

  • qwinsta: Displays information about Terminal Services sessions.
  • logoff: Logs off a user from a session and terminates the session.

For additional details and documentation on managing sessions and other advanced configurations, refer to the Microsoft official Windows Commands documentation.