📄 JScript (WSH)

Get Physical Memory Modules Report (JScript)

Queries Win32_PhysicalMemory via WMI and prints Physical Memory Modules to the console — JScript, VBScript's WSH sibling language.

By WindowsScripting.com · 1 KB
GetPhysicalMemoryReport.js
// ============================================================
// GetPhysicalMemoryReport.js
//
// Reports Physical Memory Modules via WMI (Win32_PhysicalMemory). JScript (Windows Script Host) —
// VBScript's sibling language, run the same way via cscript/wscript.
//
// Usage: cscript GetPhysicalMemoryReport.js
// ============================================================

var objWMIService = GetObject("winmgmts:\\\\.\\root\\cimv2");
var colItems = objWMIService.ExecQuery("SELECT BankLabel, Capacity, Speed, Manufacturer FROM Win32_PhysicalMemory");

var e = new Enumerator(colItems);
var output = "";
var count = 0;

for (; !e.atEnd(); e.moveNext()) {
    var item = e.item();
    output += "BankLabel: " + item.BankLabel + "\n";
    output += "Capacity: " + item.Capacity + "\n";
    output += "Speed: " + item.Speed + "\n";
    output += "Manufacturer: " + item.Manufacturer + "\n";
    output += new Array(41).join("-") + "\n";
    count++;
}

if (count === 0) {
    WScript.Echo("No Physical Memory Modules found.");
} else {
    WScript.Echo(output);
}