📄 JScript (WSH)

Get Pointing Devices Report (JScript)

Queries Win32_PointingDevice via WMI and prints Pointing Devices to the console — JScript, VBScript's WSH sibling language.

By WindowsScripting.com · 1008 B
GetPointingDeviceReport.js
// ============================================================
// GetPointingDeviceReport.js
//
// Reports Pointing Devices via WMI (Win32_PointingDevice). JScript (Windows Script Host) —
// VBScript's sibling language, run the same way via cscript/wscript.
//
// Usage: cscript GetPointingDeviceReport.js
// ============================================================

var objWMIService = GetObject("winmgmts:\\\\.\\root\\cimv2");
var colItems = objWMIService.ExecQuery("SELECT Name, Manufacturer, NumberOfButtons FROM Win32_PointingDevice");

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 += "NumberOfButtons: " + item.NumberOfButtons + "\n";
    output += new Array(41).join("-") + "\n";
    count++;
}

if (count === 0) {
    WScript.Echo("No Pointing Devices found.");
} else {
    WScript.Echo(output);
}