Is there a way using WMIC, bat files, or powershell, to kill a task with a particular task name if the amount of virtual memory the process is using is above a certain limit?

Specifically I want to kill any instance of the iexplore.exe process if its workingset (RAM usage) or Virtual memory allocation is above 1GB.

I can kill a task using taskkill using this cmd: taskkill.exe /F /IM iexplore.exe and I can filter a list of processes and their RAM usage using this cmd wmic process where "name='iexplore.exe' and workingsetsize>=1000000000" get name, workingsetsize, processid.


Here's the command that I eventually used:

PowerShell -Command "get-process | ? {$_.WorkingSet64 -gt 10000000000 -AND ($_.name -like 'java' -OR $_.name -like 'iexplore')} | foreach {kill -id $_.Id -force}"

It uses powershell to kill all processes named either java or iexplore if they exceed 1GB of RAM usage.

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.