Command-Line Tools
In addition to the graphical tools, Windows Server 2008 R2, like previous versions of Windows Server, has command-line tools that you can use to view session information, manage a session's contents, control a user's session remotely, and so forth. These command-line tools are built on the same interfaces as the graphical tools, so any information you get from one (for example, Process ID) can be used in another.
Both Windows Server 2008 R2 and Windows 7 support the Remote Desktop Services command-line tools; these tools are part of the operating system. Table-4 lists the available command-line tools.
TABLE-4 Remote Desktop Services Command-Line ToolsCommand | |
---|---|
Description | |
change logon or chglogon | Enable, disable, drain, or query information about logons from sessions on an RD Session Host server. |
change port or chgport | List or change the COM port mappings to be compatible with MS-DOS applications. |
logoff | Log off users and delete their session from the RD Session Host server. |
msg | Send a message to a user or multiple users on an RD Session Host server. |
query process or qprocess | Display information about all the processes currently running on an RD Session Host server. |
query session or qwinsta | Display information about sessions on an RD Session Host server. |
query termserver or qappsrv | List all the RD Session Host servers on a network. |
query user or quser | Display information about the users connected to an RD Session Host server. |
reset session or rwinsta | Terminate a session on an RD Session Host server. |
shadow | Enable an administrator to view or interact with an active session of another user remotely on an RD Session Host server. You must run this command from within an RDP session on an RD Session Host for it to work. |
tscon | Connect to another session on an RD Session Host server (you have to be in a remote session to connect to another remote session). |
tsdiscon | Disconnect a session from a server. |
tskill | Terminate a process running on an RD Session Host server. You can identify the process by image name or Process ID. |
tsprof | Copies the Remote Desktop Services user profile from one user to another. This command-line tool is not available for Windows 7, and although it is available for Windows Server 2008 R2, it does not work. It was used in previous versions of Terminal Services. |
The following command-line tools were removed in Windows Server 2008.
- tsshutdn: This command was used to shut down a terminal server. Use the shutdown command instead.
- register: This command was used to register a program.
- cprofile: This command was used to remove wasted space in a user profile and to delete file associations from the registry that were made to certain applications.
NOTE: For those who like working in Windows PowerShell, Shay Levy, a Windows PowerShell MVP, built a Terminal Services PowerShell Module to help manage and monitor RDS sessions and processes. Download the module at http://code.msdn.microsoft.com /PSTerminalServices. The Uniform Resource Locator (URL) is located on the companion media. This tool is good for programmatically interacting with sessions or gathering information from multiple machines.
In this tutorial:
- Managing Remote Desktop Session
- Introducing RD Session Host Management Tools
- Command-Line Tools
- Connecting Remotely to Servers for Administrative Purposes
- Managing RD Session Host Servers from Windows 7
- Organizing Servers and VMs in the Remote Desktop Services Manager
- Monitoring and Terminating Processes
- Terminating Applications
- Monitoring and Ending User Sessions
- Closing Orphaned Sessions
- Disconnecting Sessions
- Providing Help with Remote Control
- Enabling Remote Control via Group Policy
- Enabling Remote Control via RD Session Host Configuration
- Shadowing a User Session
- Troubleshooting Session Shadowing
- Preparing for Server Maintenance
- Sending Messages to Users
- Shutting Down and Restarting RD Session Host Servers
- Applying RDS Management Tools
- Get the Server Names
- List Processes on the RD Session Host Servers
- Auditing User Logons
- Closing Unresponsive Applications