Taskkill ends one or more tasks or processes. You will need taskkill command to troubleshoot issues related to your appserver, webserver domains or database if using Windows Servers as the OS platforms to host your appservers, webservers or database.
An example of a real-life issue could be that the appserver domain may give error during the bootup process due to port conflict. You may try to delete the cache folder after shutting down the appserver, but it won’t let you to.
First you will need to identify the tasks before you can kill them.
taskkill [/s Computer] [/u Domain\User [/p Password]]] [/fi FilterName] [/pid ProcessID]|[/im ImageName] [/f][/t]
/s Computer : Specifies the name or IP address of a remote computer (do not use backslashes). The default is the local computer.
/u Domain \ User : Runs the command with the account permissions of the user specified by User or Domain\User. The default is the permissions of the current logged on user on the computer issuing the command.
/p Password : Specifies the password of the user account that is specified in the /u parameter.
/fi FilterName : Specifies the types of process(es) to include in or exclude from termination. It is rare that you will need a filtername.
/pid ProcessID : Specifies the process ID of the process to be terminated.
/im ImageName : Specifies the image name of the process to be terminated. Use the wildcard (*) to specify all image names.
/f : Specifies that process(es) be forcefully terminated. This parameter is ignored for remote processes; all remote processes are forcefully terminated.
/t : Specifies to terminate all child processes along with the parent process, commonly known as a tree kill.
/? : Displays help at the command prompt.
- The wildcard character (*) is accepted only when specified along with the filters. For example: taskkill /im JSL* /F
- Termination for remote processes will always be done forcefully regardless of whether the /f parameter is specified.
- Supplying a computer name to the HOSTNAME filter will cause a shutdown and all processes will be stopped.
- Use tasklist to determine the Process ID (PID) for the process to be terminated.
taskkill /pid 4240 /F
Note that you might have to run this command as an administrator.
SUCCESS: The process with PID 4240 has been terminated.