📄 JScript (WSH)
Get Logical Disks Report (JScript)
Queries Win32_LogicalDisk via WMI and prints Logical Disks to the console — JScript, VBScript's WSH sibling language.
GetLogicalDiskReport.js
// ============================================================
// GetLogicalDiskReport.js
//
// Reports Logical Disks via WMI (Win32_LogicalDisk). JScript (Windows Script Host) —
// VBScript's sibling language, run the same way via cscript/wscript.
//
// Usage: cscript GetLogicalDiskReport.js
// ============================================================
var objWMIService = GetObject("winmgmts:\\\\.\\root\\cimv2");
var colItems = objWMIService.ExecQuery("SELECT DeviceID, VolumeName, Size, FreeSpace, DriveType FROM Win32_LogicalDisk");
var e = new Enumerator(colItems);
var output = "";
var count = 0;
for (; !e.atEnd(); e.moveNext()) {
var item = e.item();
output += "DeviceID: " + item.DeviceID + "\n";
output += "VolumeName: " + item.VolumeName + "\n";
output += "Size: " + item.Size + "\n";
output += "FreeSpace: " + item.FreeSpace + "\n";
output += "DriveType: " + item.DriveType + "\n";
output += new Array(41).join("-") + "\n";
count++;
}
if (count === 0) {
WScript.Echo("No Logical Disks found.");
} else {
WScript.Echo(output);
}