11

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.

Rationale
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 :-)

5

In powershell you would do:

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

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".

  • 1
    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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.