I'm writing a batch file to monitor a particular process every couple of minutes and if the memory of this process is over a certain threshold, it is killed and then restarted.
I have this working now, but the problem I'm facing is when there are multiple instances of the same process. E.G. Each tab open in the Chrome web browser, uses it's own instance of Chrome.exe with a unique PID.
When I use the command
Code: Select all
tasklist /fi "imagename eq chrome.exe"
Code: Select all
for /f "tokens=2,3" %%A in ('tasklist /nh /fi "imagename eq chrome.exe"') do set PID=%%A
Code: Select all
tasklist | find /I /C "chrome.exe"
Would anyone be able to comment if this is at all possible and if so, any example code?
Thanks in advance!