QWinsta - CMD


The QWinsta command, short for Query WINdows STAtion, displays information about Remote Desktop sessions on a Windows server or workstation. It’s primarily used by administrators to monitor user sessions, including their current state and IDs. Effective use cases involve managing and troubleshooting Remote Desktop Services.


The general syntax for QWinsta is as follows:

QWinsta [SessionName | SessionID] [/server:ServerName]
  • SessionName: Name of the session to query.
  • SessionID: Numerical ID of the session.
  • /server:ServerName: Specifies the server on which to query the session(s).


  • SessionName: Optional. Include this to see details about a specific session by name.
  • SessionID: Optional. Use this to inquire about a specific session using its numerical ID.
  • /server: This option allows the user to specify a remote server for the query. If omitted, the command targets the local machine.


  1. Query All Sessions on Local Machine:


    This basic command displays all sessions on the local machine.

  2. Query Specific Session by ID:

    QWinsta 1

    Replace 1 with the actual session ID to get details about that session.

  3. Query Sessions on a Remote Server:

    QWinsta /server:

    Replace with the actual server IP or hostname to check the sessions on that remote machine.

Common Issues

  • Access Denied: This error occurs if the user does not have sufficient permissions to query the sessions. Ensure you run the command prompt as an administrator or have the necessary remote rights.
  • Invalid Parameter: This can occur if an incorrect session name or ID is specified. Verify the input parameters are correct.

Ensure administrative privileges and correct parameter usage.


QWinsta can be effectively combined with the rwinsta command to reset sessions, based on the output from qwinsta. Here is an example of a simple script:

for /f "skip=1 tokens=1" %%s in ('qwinsta /server:myserver') do (
    rwinsta %%s /server:myserver

This script queries all sessions on myserver and resets them.

  • RWinsta: Resets the session sub-system hardware and software to known initial values.
  • Msg: Sends a message to a user on a specific session.

For further reading, official Microsoft documentation on these commands can be helpful for a deeper understanding and exploration of additional parameters and examples: