From 157d723b4485899e5b1f912f7573dad2a4605683 Mon Sep 17 00:00:00 2001 From: "Namhyeon, Go" Date: Mon, 11 Apr 2022 11:15:30 +0900 Subject: [PATCH] Update wmi.js --- lib/wmi.js | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/lib/wmi.js b/lib/wmi.js index 10374d0..b4720c7 100644 --- a/lib/wmi.js +++ b/lib/wmi.js @@ -25,14 +25,17 @@ var WMIQueryObject = function() { } return this; }; + this.setComputer = function(computer) { this.computer = computer; return this; }; + this.setNamespace = function(namespace) { this.namespace = namespace; return this; }; + this.execQuery = function(query) { try { var result = this.interface.ExecQuery(query, "WQL", wbemFlagReturnImmediately | wbemFlagForwardOnly); @@ -42,6 +45,7 @@ var WMIQueryObject = function() { } return this; }; + this.fetch = function() { if (!this.cursor.atEnd()) { this.current = this.cursor.item(); @@ -49,9 +53,15 @@ var WMIQueryObject = function() { } return this; }; + this.fetchAll = function() { return this.cursor.toArray(); }; + + this.fetchAll2 = function() { + return this.cursor.toArray2(); + }; + this.get = function(key) { if (key in this.current) { return this.current[key]; @@ -79,16 +89,20 @@ var WMIClassObject = function() { this.classObject = this.interface.Get(className); return this; }; + this.create = function() { this.instance = this.classObject.SpawnInstance_(); return this; }; + this.getAttribute = function(key) { return this.instance[key]; }; + this.setAttribute = function(key, value) { this.instance[key] = value; }; + this.getInstance = function() { return this.instance; }; @@ -99,10 +113,12 @@ var WMIClassObject = function() { this.methodObject = this.classObject.Methods_.Item(methodName); return this; }; + this.setParameter = function(key, value) { this.inParams[key] = value; return this; }; + this.setParameters = function(params) { if (typeof(params) !== "undefined") { for (k in params) { @@ -111,6 +127,7 @@ var WMIClassObject = function() { } return this; }; + this.execute = function() { var params = this.methodObject.InParameters.SpawnInstance_(); for (k in this.parameters) { @@ -119,6 +136,7 @@ var WMIClassObject = function() { this.outParams = this.classObject.ExecMethod_(this.methodName, params); return this; }; + this.get = function(key) { if (key in this.outParams) { return this.outParams[key]; @@ -138,4 +156,4 @@ exports.setClass = function(className) { exports.VERSIONINFO = "WMI interface (wmi.js) version 0.1"; exports.global = global; -exports.require = global.require; \ No newline at end of file +exports.require = global.require;