Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Before I look into reinventing the wheel and roll my own, is anyone aware of an application/utility that allows me to kill processes, filtering by both process name and process owner? Alternatively could this be done through powershell? (My powershell-fu is sadly lacking).

I've looked at both pskill and taskkill. Although pskill allows terminating by process name, it doesn't allow me to further filter by process owner. I've also looked at WMI via wmic (wmic process), but the WMI interface doesn't return the process owner (at least from what I can tell), so can't use this either.

I do a chunk of development on Windows. Some of this involves dealing with Component Services (COM+). COM+ has a generic host process - dllhost.exe - that's used both for custom (i.e., stuff I've developed) elements and system processes. I can differentiate them by the owner they run as. So, for example, I want to kill all the dllhost.exe processes owned by me, but ignore the ones owned by SYSTEM.

This would save me going in to Task Manager on a regular basis and identifying and manually killing each one :-)

share|improve this question
up vote 4 down vote accepted

In powershell you would do:

gwmi -query "select * from win32_process where name='PROCESSNAME.exe'" | %{if($_.GetOwner().User -eq 'USERNAME'){$_.terminate()}}
share|improve this answer
Ah -- excellent cheers. That works nicely :-) – Chris J Jan 5 '12 at 16:40

You weren't looking hard enough.

taskkill /f /fi "imagename eq foo.exe" /fi "username eq Chris"

You can even filter by modules loaded, using /fi "modules eq libfoo.dll".

share|improve this answer
Much easier than the PS method :) – EBGreen Jan 5 '12 at 18:37
You're right -- I wasn't looking hard enough. That's bad of me. – Chris J Jan 6 '12 at 9:02

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .