Windows 7 / Getting Started

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
[Previous] [Contents] [Next]