Windows 7 / Getting Started

Disconnecting Sessions

Disconnecting a session using the Remote Desktop Services Manager is easy. Find the session to disconnect, right-click it, and choose Disconnect from the context menu. You must be connected to the same server as the session you're disconnecting.

To disconnect a session from the command prompt, use tsdiscon. The syntax is simple.

TSDISCON 		[sessionid/sessionname] [/SERVER:servername] [/V]
 Sessionid 		The ID of the session.
 Sessionname 		The name of the session.
 /SERVER:servername 	Specifies the RD Session Host server (default is current).
 /V 			Displays information about the actions performed.

As you can see, when using the command-line tool, you can specify the server on which you want to disconnect a session.

CAUTION: If you run tsdiscon without arguments, you'll disconnect your own session even if you're sitting at the console. You won't lose any data because the session will continue running and you can just reconnect, but disconnecting yourself is disconcerting and should be avoided.

Terminating Sessions

You can terminate a session easily from the Remote Desktop Services Manager or the command prompt.

To terminate a session from the Remote Desktop Services Manager, highlight the session on the Users or Sessions tab, right-click, and choose Reset. You'll see a dialog box telling you that you're resetting this user's session. Click OK, and then the session will reset. All processes belonging to that user will be terminated immediately.

You can also terminate active and disconnected sessions from the command line using one of these three utilities (their syntax is shown here).

RESET SESSION {sessionname | sessionid} [/SERVER:servername] [/V]
RWINSTA {sessionname | sessionid} [/SERVER:servername] [/V]
LOGOFF [sessionname | sessionid] [/SERVER:servername] [/V]

Reset session and rwinsta are functionally the same in that they terminate the connection ungracefully-the session never has a chance to close open files or save the profile changes. Logoff is a little different in that, although it won't save open files, it will at least write back changes to the profile.

The syntax for all three commands requires that you use the session name or session ID to identify the session you want to close, so you will need to get this information from the Remote Desktop Services Manager or from the command line by using the query user command. The syntax is

QUERY USER [username | sessionname | sessionid] [/SERVER:servername]

For instance, to reset a disconnected session for user marlon.sam on server FUJI, run these commands. The following example checks for Marlon's session after resetting it just to make the point that this session no longer exists.

C:\Users\Administrator>query session marlon.sam /server:FUJI
		marlon.sam 	5    Disc

C:\Users\Administrator>reset session 5 /server:FUJI
C:\Users\Administrator>query session marlon.sam /server:FUJI
No session exists for marlon.sam
[Previous] [Contents] [Next]