For a second time now, I’ve found myself needing to kill processes in my automated build scripts, so that was enough for me to automate it and wrap it up in a custom NAnt task. The first time I needed it, I just embedded the C# code inside a NAnt script block, but using it as “real” NAnt task is much nicer. And, perhaps I overlooked it, but I did not see a task in the set of NAnt or NAntContrib tasks to do this kind of simple operation and Google didn’t turn up anything either. So I just banged it out real quick…
Here’s how it can be used:
And for those that are interested, here’s the code for the task, although it’s really quite simple:
Disclaimer: I take no responsibility for what happens if try to pass in a process name like “System” or “winlogon” or “explorer”. So please use wisely… 🙂
As usual, you can grab the source code yourself from the repository.