In tip 7306, I described the SystemInfo.exe utility.

I have scripted PhysicalMemory.bat to return the amount of RAM, and the unit of measure.

The syntax for using PhysicalMemory.bat is:

PhysicalMemory Number Units

Where Number is a call directed numeric environment variable that will contain the amount of RAM, and Units is a call directed environment variable that will contain the units.

Example:

<b>. . .
call PhysicalMemory Number Units
@echo %Number% %Units%
. . .</b>
displays 1023 MB on my desktop computer.

PhysicalMemory.bat contains:

@echo off
if \{%2\}==\{\} @echo Syntax: PhysicalMemory Number Units&goto :EOF
for /f "tokens=4,5" %%a in ('systeminfo^|find "Total Physical Memory"') do (
 set %1=%%a
 set %2=%%b
)
call set /a %1=%%%1:,=%%