Monitoring Mem Usage of specific process on XP

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
mr_wizard
Posts: 14
Joined: 11 Jul 2012 12:46

Monitoring Mem Usage of specific process on XP

#1 Post by mr_wizard » 18 Jul 2012 08:11

Trying to keep something running in the background to monitor the memory usage (as seen in Process in Task Manager) of a specific process and when a specific size is met to create a dialog box with a message. So it would simply loop until it's found. I've tried several variations to no avail. Anyone mind taking a look? This is what I got:

:loop
Sleep 1
TASKLIST /FI "IMAGENAME eq explorer.exe" /FI "MEMUSAGE ge 30000"
if ERRORLEVEL 1 (goto :loop) else (goto :announce)

:announce
echo MSGBOX "Internet Explorer is not responding. Reference code: 1x000133t" > %temp%\TEMPmessage.vbs
call %temp%\TEMPmessage.vbs
del %temp%\TEMPmessage.vbs /f /q

exit


The way I test is simply modifying the size (i.e. 30000) which is denoted in KB's. I modify the size either intentionally larger or smaller (since the operation "ge" is greater than or equal) which does not effect whether the message occurs or not.

Thanks everyone!

mr_wizard
Posts: 14
Joined: 11 Jul 2012 12:46

Re: Monitoring Mem Usage of specific process on XP

#2 Post by mr_wizard » 18 Jul 2012 08:22

Well found a work around, seems to be working.

:loop
Sleep 3
TASKLIST /FI "IMAGENAME eq explorer.exe" /FI "MEMUSAGE ge 6000" | find /i /c "explorer.exe"
if errorlevel 1 goto :loop
if errorlevel 0 goto :announce

:announce
echo MSGBOX "Internet Explorer is not responding. Reference code: 1x000133t" > %temp%\TEMPmessage.vbs
call %temp%\TEMPmessage.vbs
del %temp%\TEMPmessage.vbs /f /q

exit

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: Monitoring Mem Usage of specific process on XP

#3 Post by foxidrive » 18 Jul 2012 09:48

This should work too.

Code: Select all

:loop
Sleep 3
TASKLIST /FI "IMAGENAME eq explorer.exe" /FI "MEMUSAGE ge 6000" | find /i "explorer.exe" >nul || goto :loop
echo MSGBOX "Internet Explorer is not responding. Reference code: 1x000133t" > %temp%\TEMPmessage.vbs
call %temp%\TEMPmessage.vbs
del %temp%\TEMPmessage.vbs

Post Reply