The QUSER command in Windows CMD is used to display information about user sessions on a system. It’s primarily designed for administrators to quickly get details about which users are currently logged on to the server, along with their session types, idle time, and login time. This is especially useful in server environments and for remote session management.


The basic syntax for the QUSER command is:

QUSER [username | sessionname | sessionid]
  • username: Specifies the logon user name to query.
  • sessionname: Specifies the name of the session to query.
  • sessionid: Specifies the ID identifying the session to query.

If no arguments are provided, QUSER will display information for all users logged onto the machine.


QUSER does not have additional flags or options other than the identifiers for users, sessions, or session IDs. The lack of extra options keeps the command straightforward to use for its intended purpose.


  1. View all user sessions:


    This command lists all active user sessions on the system.

  2. Look up a specific user:

    QUSER username

    Replace username with the actual user name to display sessions related to that user.

  3. Query by session ID:

    QUSER 1

    This returns information about the session with session ID 1.

Common Issues

  • Session details not updating: Users may sometimes find that the session details aren’t updating in real-time. This can be managed by frequently refreshing the command output in scripts or manual re-invocation.
  • Access denied: Non-administrator users may encounter access restrictions. Ensure appropriate permissions when attempting to query session information.


Combine with LOGOFF:

To forcefully log off a user after identifying their session ID with QUSER, you can use:

QUSER username
LOGOFF sessionid

Scripting Example:

This is an example of a simple batch script that checks for a user’s session and logs them off:

FOR /F "tokens=1,2 delims= " %%i in ('QUSER username') DO (
    IF %%j EQU username (
        LOGOFF %%i

This script loops through the output of QUSER, checks if the specified username is found, and logs that session out.

  • QUERY SESSION: Similar to QUSER, used to query sessions.
  • LOGOFF: Logs off a user from a session.
  • TSKILL: Can be used to terminate processes based on the session/user information from QUSER.

For more details and documentation, Microsoft’s official command-line reference can be visited: Windows Commands.

This manual provides a practical and succinct guide to using the QUSER command effectively in Windows CMD environments.