I have a bunch of console host applications hosting WCF services. I'm calling a .bat file as a pre build step to kill any running host instances so that I don't get WCF channel registrations errors(manually killing the console hosts each time before a build is a royal pain).
The .bat file I've created contains the following.
taskkill /T /F /FI "imagename eq Host.vshost.exe"
taskkill /T /F /FI "imagename eq Host.exe"
exit /B 0
This kills both processes. I can see in taskmanager that Host.exe is gone and Host.vshost.exe has a new PID but the Console Window is still up. It seems that cmd.exe is the actual process hosting the console so I then changed the .bat file to this..
taskkill /T /F /FI "imagename eq cmd.exe"
But this kills all cmd.exe windows.
How can I tweak this so that i can target just the specific Console application's cmd window or is there a different command I should be using?