Windows – Kill specific instance of process on windows

killmultiple instancesprocesswindows

I could not find help to this specific question, and I wonder if it has a solution. I have multiple instances of a program running on Windows 7. How can I kill a specific window (maybe based on the filename that is open)?

Background:
I have a client application for an ETL software (SAS EG) on my desktop and routinely something goes wrong and a session freezes. But I have many sessions open at the same time, i.e. multiple instances of the program running on my desktop, each having their own session on the remote server. I want to kill just the one that freezed and continue working with the other instances. I know it's possible, I can kill a single instance from Task Manager, but it's a russian roulette since the processes can't be distinguished from one another in Task Manager afaik. Thanks a lot for any help.

Best Answer

How can I kill a specific window (maybe based on the filename that is open)?

the windows have different titles according to the filename that is open (in this case project name).

You can use taskkill to kill processes that have windows with a specified title.

Example

Given the following window:

enter image description here

The command to kill that instance of notepad which is editing a file called test.txt is:

taskkill /f /fi "windowtitle eq test.txt*"

Output:

>taskkill /f /fi "windowtitle eq test.txt*"
SUCCESS: The process with PID 5356 has been terminated.

Notes:

  • Replace test.txt* with a string that uniquely identifies your application's window.

Further Reading

Related Question