Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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

share|improve this question

2 Answers 2

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

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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