📄 JScript (WSH)

Get Computer System Info Report (JScript)

Queries Win32_ComputerSystem via WMI and prints Computer System Info to the console — JScript, VBScript's WSH sibling language.

By WindowsScripting.com · 1.1 KB
GetComputerSystemReport.js
// ============================================================
// GetComputerSystemReport.js
//
// Reports Computer System Info via WMI (Win32_ComputerSystem). JScript (Windows Script Host) —
// VBScript's sibling language, run the same way via cscript/wscript.
//
// Usage: cscript GetComputerSystemReport.js
// ============================================================

var objWMIService = GetObject("winmgmts:\\\\.\\root\\cimv2");
var colItems = objWMIService.ExecQuery("SELECT Name, Manufacturer, Model, TotalPhysicalMemory, NumberOfProcessors FROM Win32_ComputerSystem");

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

for (; !e.atEnd(); e.moveNext()) {
    var item = e.item();
    output += "Name: " + item.Name + "\n";
    output += "Manufacturer: " + item.Manufacturer + "\n";
    output += "Model: " + item.Model + "\n";
    output += "TotalPhysicalMemory: " + item.TotalPhysicalMemory + "\n";
    output += "NumberOfProcessors: " + item.NumberOfProcessors + "\n";
    output += new Array(41).join("-") + "\n";
    count++;
}

if (count === 0) {
    WScript.Echo("No Computer System Info found.");
} else {
    WScript.Echo(output);
}