JSI Tip 9799. How can I determine the Total Physical Memory, Available Physical Memory, Total Virtual Memory, and Available Virtual Memory in my computer?

I have scripted RAM.bat to retrieve the Total Physical Memory, Available Physical Memory, Total Virtual Memory, and Available Virtual Memory in your computer.

The syntax for using RAM.bat is:

RAM TPM APM TVM AVM

Where:

TPM is a call directed environment variable that will contain the Total Physical Memory in megabytes, with 2 decimal places.

APM is a call directed environment variable that will contain the Available Physical Memory in megabytes, with 2 decimal places.

TVM is a call directed environment variable that will contain the Total Virtual Memory in gigabytes, with 2 decimal places.

AVM is a call directed environment variable that will contain the Available Virtual Memory in gigabytes, with 2 decimal places.
RAM.bat contains:
@echo Off
if \{%4\}==\{\} @echo Syntax: RAM TPM APM TVM AVM&goto :EOF
setlocal ENABLEDELAYEDEXPANSION
set file="%TEMP%\memory_%RANDOM%.TMP"
if exist %file% del /q /f %file%
msinfo32.exe /categories SystemSumary /report %file%
set /a cnt=0
set TPM=0.00
set APM=0.00
set TVM=0.00
SET AVM=0.00
for /f "Tokens=1-5" %%a in ('type %file%^|find "Memory"') do (
 set /a cnt=!cnt! + 1
 if !cnt! EQU 1 set TPM=%%d&set TPM=!TPM:,=!
 if !cnt! EQU 2 set APM=%%d&set APM=!APM:,=!
 if !cnt! EQU 3 set TVM=%%d&set TVM=!TVM:,=!
 if !cnt! EQU 4 set AVM=%%d&set AVM=!AVM:,=!
)
del /f /q %file%
endlocal&set TPM=%TPM%&set APM=%APM%&set TVM=%TVM%&set AVM=%AVM%



Hide comments

Comments

  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
Publish