Rob van der Woude's Scripting Pages
Powered by GeSHi

Source code for memory.bat

(view source code of memory.bat as plain text)

  1. @ECHO OFF
  2. IF [%1]==[] GOTO Begin
  3. ECHO.
  4. ECHO Memory.bat, Version 1.01 for NT 4 with Resource Kit
  5. ECHO Displays the amount of RAM installed on this PC in MB
  6. ECHO.
  7. ECHO Written by Rob van der Woude
  8. ECHO http://www.robvanderwoude.com
  9. ECHO.
  10. ECHO Use GETRAM.BAT instead if you do not have a copy of the Windows
  11. ECHO NT Resource Kit available.
  12. ECHO GETRAM.BAT is based on an idea posted on alt.msdos.batch.nt by
  13. ECHO Mike Castle. It uses NT's native WINMSD.EXE instead of PSTAT.EXE
  14. ECHO from the Resource Kit. However, it is much slower than this batch
  15. ECHO file.
  16. ECHO GETRAM.BAT is available at http://www.robvanderwoude.com too.
  17. ECHO.
  18. ECHO Total installed RAM in MB:
  19.  
  20. :Begin
  21. :: Use PSTAT.EXE from the NT 4 Resource Kit
  22. :: to find the amount of RAM installed (in KB)
  23. FOR /F "tokens=2 delims=K " %%A IN ('PSTAT ^| FIND "Memory:"') DO SET RAM=%%A
  24. :: The following command line is added to round up instead of down;
  25. :: change the value from 1023 to 512 for "mathematical" rounding,
  26. :: or remove the line to round down
  27. SET /A RAM = %RAM% + 1023
  28. :: Convert from KiloBytes to MegaBytes
  29. SET /A RAM = %RAM% / 1024
  30. :: Display the result
  31. ECHO.%RAM%
  32.  

page last modified: 2024-02-26; loaded in 0.0153 seconds