📄 JScript (WSH)

Get Operating System Info Report (JScript)

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

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

var objWMIService = GetObject("winmgmts:\\\\.\\root\\cimv2");
var colItems = objWMIService.ExecQuery("SELECT Caption, Version, OSArchitecture, LastBootUpTime, FreePhysicalMemory FROM Win32_OperatingSystem");

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

for (; !e.atEnd(); e.moveNext()) {
    var item = e.item();
    output += "Caption: " + item.Caption + "\n";
    output += "Version: " + item.Version + "\n";
    output += "OSArchitecture: " + item.OSArchitecture + "\n";
    output += "LastBootUpTime: " + item.LastBootUpTime + "\n";
    output += "FreePhysicalMemory: " + item.FreePhysicalMemory + "\n";
    output += new Array(41).join("-") + "\n";
    count++;
}

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