Skip to content

How to Get Memory Chip Details (RAM Sticks) in a Batch Script

Learn how to retrieve detailed RAM module information (including capacity, speed, manufacturer, and slot) using the WMIC MEMORYCHIP command in Windows batch scripts for hardware auditing and troubleshooting.

When auditing a computer's hardware, simply knowing the total amount of installed RAM isn't always enough. For system inventory, upgrade planning, or troubleshooting, you often need specific details about each individual memory module (RAM stick), such as its capacity, speed, manufacturer, and which slot it's installed in.

This guide will teach you how to retrieve this detailed hardware information using the powerful, built-in WMIC (Windows Management Instrumentation) command. You will learn the correct query to use, how to parse the output to create a report for each memory module, and how to convert the raw data into a human-readable format.

The Core Command: WMIC MEMORYCHIP

The WMIC (Windows Management Instrumentation Command-line) utility is the definitive tool for querying system hardware information from a script. The MEMORYCHIP alias provides direct access to the data stored in the firmware (SMBIOS) about each physical memory module installed in the system.

Command: WMIC MEMORYCHIP GET Capacity,Manufacturer,PartNumber,Speed

  • MEMORYCHIP: The WMI class for physical RAM modules.
  • GET ...: Specifies the properties you want to display.

Basic Example: A Simple List of All Memory Chips

Running the basic WMIC command gives you a formatted table of all installed RAM sticks and their properties.

@ECHO OFF
ECHO --- Querying all installed memory modules ---
ECHO This may take a moment...
ECHO.

WMIC MEMORYCHIP GET Capacity,DeviceLocator,Manufacturer,Speed

PAUSE

The command produces a clean table, with one row for each memory stick found. The Capacity is shown in bytes.

Capacity      DeviceLocator  Manufacturer  Speed
17179869184   ChannelA-DIMM0 Hynix/Hyundai 1600
17179869184   ChannelB-DIMM0 Hynix/Hyundai 1600

This shows a system with two 16 GB sticks of RAM.

Parsing the Output with FOR /F for a Detailed Report

To use this information in a script, you need to process the output line by line. The FOR /F loop is the standard tool for this, allowing you to work with the details of each memory chip individually.

This script iterates through each memory chip and prints a formatted line of information.

@ECHO OFF
ECHO --- Iterating through each memory module ---
ECHO.

REM The 'skip=1' ignores the header line of the WMIC output.
FOR /F "skip=1 tokens=*" %%C IN ('WMIC MEMORYCHIP GET Manufacturer') DO (
    IF NOT "%%C"=="" ECHO Found a chip from manufacturer: "%%C"
)

Key WMIC MEMORYCHIP Properties Explained

You can GET many useful properties from the MEMORYCHIP class:

Property Description Example Value
DeviceLocator The physical slot the chip is in. ChannelA-DIMM0
Capacity The size of the module in bytes. 17179869184 (for 16 GB)
Speed The configured speed of the module in MHz. 3200
Manufacturer The name of the chip manufacturer. Kingston, Crucial
PartNumber The manufacturer's part number for the module. CMK32GX4M2B3200C16
SerialNumber The unique serial number of the module. E1A2B3C4
FormFactor A numeric code for the physical type. 8 (DIMM for desktops), 12 (SODIMM for laptops)

Common Pitfalls and How to Solve Them

  • Administrator Rights: For the most reliable and complete hardware information, you must run the script as an Administrator.

  • Capacity is in Bytes: The Capacity value is a very large number representing bytes. It is not human-readable.

    • Solution: You must convert this value to a more useful unit like Gigabytes (GB) in your script. The formula is GB = Bytes / 1073741824. Because this number is larger than SET /A's 32-bit limit, this calculation is best done with PowerShell.
  • Information Accuracy: The data provided by WMIC is only as accurate as the information programmed into the chip's SPD (Serial Presence Detect) by the manufacturer. Some generic or budget RAM sticks may show "Unknown" or a generic part number.

Practical Example: A Full RAM Inventory Report Script

This script uses a robust FOR /F loop to iterate through all memory chips. For each one, it converts the capacity to GB and prints a clean, detailed report.

@ECHO OFF
SETLOCAL ENABLEDELAYEDEXPANSION

ECHO --- Detailed System RAM Inventory ---
ECHO.

REM Use CSV format for reliable parsing, skip the header line.
FOR /F "skip=1 delims=" %%L IN ('WMIC MEMORYCHIP GET Capacity^,DeviceLocator^,Manufacturer^,PartNumber^,Speed /FORMAT:CSV') DO (
    REM WMIC CSV format is Node,Property1,Property2,...
    FOR /F "tokens=2-6 delims=," %%A IN ("%%L") DO (
        SET "CapacityBytes=%%A"
        SET "Slot=%%B"
        SET "Mfg=%%C"
        SET "PartNum=%%D"
        SET "Speed=%%E"
        
        REM Clean the variables of any invisible trailing characters.
        FOR %%N IN ("!CapacityBytes!") DO SET "CapacityBytes=%%~N"
        FOR %%N IN ("!Slot!") DO SET "Slot=%%~N"
        FOR %%N IN ("!Mfg!") DO SET "Mfg=%%~N"
        FOR %%N IN ("!PartNum!") DO SET "PartNum=%%~N"
        FOR %%N IN ("!Speed!") DO SET "Speed=%%~N"
        
        REM Use PowerShell for the GB calculation due to 32-bit limits.
        FOR /F %%G IN ('powershell -Command "!CapacityBytes! / 1GB"') DO SET "CapacityGB=%%G"
        
        ECHO =======================================
        ECHO Slot:         !Slot!
        ECHO Manufacturer: !Mfg!
        ECHO Capacity:     !CapacityGB! GB
        ECHO Speed:        !Speed! MHz
        ECHO Part Number:  !PartNum!
    )
)

ENDLOCAL

Conclusion

The WMIC MEMORYCHIP command is the standard and most effective built-in tool for getting detailed information about each physical RAM stick installed in a Windows machine.

  • The core command is WMIC MEMORYCHIP GET <Properties>.
  • For scripting, it is best to use /FORMAT:CSV and parse the output with a FOR /F loop.
  • Always run your script as an Administrator for accurate results.
  • Remember that the Capacity is in bytes and should be converted to GB for readability, preferably with a call to PowerShell to handle the large numbers.
Navigation