Update wmi.js

This commit is contained in:
Namhyeon Go 2022-04-11 11:15:30 +09:00 committed by GitHub
parent 8eb7e2ede0
commit 157d723b44
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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;
exports.require = global.require;