Computer and Software Support


Query session 

This page is from Microsoft

Updated: January 21, 2005

Displays information about sessions on a terminal server. The list includes information not only about active sessions but about other sessions that the server runs.
 
 
Syntax
query session [{SessionName | UserName | SessionID}] [/server:ServerName] [/mode] [/flow] [/connect] [/counter]
Parameters
SessionName
The name of the session you want to query.
UserName
The name of the user whose sessions you want to query.
SessionID
The ID of the session you want to query.
/server:ServerName
Identifies the terminal server to query. The default is the current server.
/mode
Displays current line settings.
/flow
Displays current flow-control settings.
/connect
Displays current connect settings.
/counter
Displays current counters information, including the total number of sessions created, disconnected, and reconnected.
/?
Displays help at the command prompt.
Remarks
  • A user can always query the session to which the user is currently logged on. To query other sessions, the user must have Query Information access permission.
  • If you do not specify a session using SessionName, UserName, or SessionID, query session displays information about all active sessions in the system.
  • When query session returns information, a less than (>) symbol is displayed before the current session. Following is sample output for query session:
    C:\>query session
     SESSIONNAME    USERNAME       ID STATE  TYPE   DEVICE
    >console        administrator   0 active wdcon
     rdp-tcp#1      client1         1 active wdtshare
     rdp-tcp                        2 listen wdtshare
                                    4 idle
                                    5 idle

    The less than (>) symbol indicates the current session. SESSIONNAME specifies the name assigned to the session. USERNAME indicates the user name of the user connected to the session. STATE provides information about the current state of the session. TYPE indicates the session type. DEVICE, which is not present for the console or network-connected sessions, is the device name assigned to the session. The comment following session information is from the session profile. Any sessions in which the initial state is configured as DISABLED do not show up in the query session list until they are enabled.

     

Examples
To display information about all active sessions on server SERVER2, type:

query session /server:SERVER2

To display information about active session MODEM02, type:

query session MODEM02

Formatting legend

Format Meaning
Italic Information that the user must supply
Bold Elements that the user must type exactly as shown
Ellipsis (...) Parameter that can be repeated several times in a command line
Between brackets ([]) Optional items
Between braces ({}); choices separated by pipe (|). Example: {even|odd} Set of choices from which the user must choose only one
Courier font Code or program output