TSKILL - CMD


Overview

TSKILL is a command-line utility available in Windows operating systems that is used to terminate tasks by their process ID or image name. This command is particularly useful for system administrators and advanced users to quickly kill unresponsive applications or processes that are consuming too many resources. It can be effectively used in batch scripts or for system management tasks to maintain or troubleshoot Windows environments.

Syntax

The basic syntax of the TSKILL command is as follows:

TSKILL processid | processname [/SERVER:servername] [/ID:sessionid | /A] [/V]
  • processid: Specifies the process ID of the task to be terminated.
  • processname: Specifies the name of the task to be terminated.

Parameters:

  • /SERVER:servername: (Optional) Defines the Terminal server containing the process that you want to terminate. If not specified, the command targets the local server.
  • /ID:sessionid: (Optional) Terminates the process running under the specified session ID.
  • /A: (Optional) Indicates to terminate a process running on all sessions.
  • /V: (Optional) Enables verbose mode, showing detailed information about actions being performed.

Options/Flags

  • /SERVER:servername
    • Used to specify a remote server where the process will be terminated.
  • /ID:sessionid
    • Useful for multi-user environments, allowing specific processes within a particular session to be targeted.
  • /A
    • Terminate processes across all sessions, typically used in scenarios where the same process may be causing issues across multiple user sessions.
  • /V
    • Displays additional details about the task termination process which can be useful for debugging purposes.

Examples

  1. Terminate a process by its ID on the local system:
    TSKILL 1234
    
  2. Terminate a process by name:
    TSKILL notepad
    
  3. Terminate a process by ID on a remote server:
    TSKILL 5678 /SERVER:Server01
    
  4. Terminate all instances of a process across all sessions:
    TSKILL chrome /A
    
  5. Verbosely terminate a process by ID and session:
    TSKILL 1234 /ID:2 /V
    

Common Issues

  • Process Not Found: If the specified process ID or name does not exist, TSKILL will fail with an error. Ensure the correct ID or name is used.
  • Permissions: Without sufficient privileges, attempting to terminate tasks can result in access denied errors. Running the command prompt as an administrator can resolve this.
  • Remote Terminations: Network issues or incorrect server names can lead to failures when using the /SERVER flag. Verify network connectivity and server access permissions.

Integration

TSKILL can be combined with other commands to automate complex tasks:

  • Use with TASKLIST to filter and terminate specific processes:
    FOR /F "tokens=2" %%G IN ('TASKLIST /FI "IMAGENAME eq notepad.exe"') DO TSKILL %%G
    
  • TASKKILL: Another utility for terminating tasks that offers more options and control, such as the ability to force terminate tasks and terminate child processes.
  • TASKLIST: Displays a list of currently running processes, useful for obtaining process IDs and session data needed by TSKILL.

For more details, here are useful links to Microsoft’s official documentation: