@echo off REM Name: showmemusage.bat REM Created: November 25, 2014 REM Last Modified: November 25, 2014 REM Version: 1.0 REM REM Description: calculates the total amount of memory used by all instances REM of a specified process name. The name can be placed on the command line, REM e.g., "showmemusage chrome.exe". If none is included on the command line, REM i.e., the batch file is run with "showmemusage", it will prompt for a REM process name. The total memory usage derived from the tasklist command REM will be displayed in kilobytes (KB). See REM http://support.moonpoint.com/os/windows/commands/batch/showmemusage.php setlocal EnableDelayedExpansion set total=0 REM If no process name was entered on the command line, prompt for the process REM name. IF [%1]==[] ( set /p pname="Process name: " ) ELSE ( set pname=%1 ) for /f "tokens=5" %%i in ('tasklist /fi "imagename eq %pname%" ^| findstr " K$" ') do ( set pmemuse=%%i REM eliminate the comma from the number set pmemuse=!pmemuse:,=! set /a total=!total! + !pmemuse! ) echo %total% K