Terminating Applications
When you know where an application is running, you can terminate it if you need to. A user's application might be unresponsive or a user might get past your lockdown schemes. It's even possible to terminate a process for one user so that another user can use it without violating your application licensing. To terminate a process from the Remote Desktop Services Manager, connect to the server or VM where the process is running, select the Processes tab, right-click the process, and choose End Process.
You also can end a process from the command line by running the tskill command. The syntax is
TSKILL processid/processname [/SERVER:servername] [/ID:sessionid//A] [/V] processid Process ID for the process to be terminated. processname Process name to be terminated. /SERVER:servernameThe RD Session Host server or VM where the process is running (if not specified, the local machine is the default). /ID or /A must be specified when using processname and /SERVER /ID:sessionid End process running under the specified session. /A End process running under ALL sessions. /V Display information about actions being performed.
Notice that you can kill either a specific instance of an application on a server or all instances. To terminate an application running in a specific session, use the /ID:sessionid parameter to specify that session. You need to know the session ID where the process is running, so you must first run the query session command to find out what the session ID is.
To illustrate, let's combine these two commands to effectively shut down one instance of an application. This example will terminate the Excel.exe process running in the session for user on server FUJI. First, run the query session command to find the correct session ID.
C:\windows\system32>query session /server:FUJI SESSIONNAME USERNAME ID STATE TYPE DEVICE services 0 Disc console Administrator 1 Active rdp-tcp#1 jimy.barr 2 Active rdpwd rdp-tcp#0 administrator 3 Active rdpwd joe.hanry 4 Disc katy.marin 5 Disc karla.nanson 6 Disc rdp-tcp 65536 Listen
Then terminate Microsoft Excel by specifying the process name, the server, and the session ID.
C:\windows\system32>tskill excel /server:FUJI /ID:2
NOTE: Notice that the process name is equivalent to the name of the executable minus the extension. Leaving off the extension is important; although executable names normally include the extension, the command won't work if you include it.
What if you forget to disable installations and discover a tennis tournament taking place among the users on an RD Session Host server? You can also terminate a process (in this example, tennis) running in all sessions on an RD Session Host server by using the /A switch in this way.
tskill tennis /server:FUJI /A
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