Update wmi.js

This commit is contained in:
Namhyeon Go 2020-11-15 04:30:18 +09:00
parent c60e3b157f
commit 1167c6ab84

View File

@ -6,19 +6,24 @@ var WMIObject = function() {
var wbemFlagReturnImmediately = 0x10;
var wbemFlagForwardOnly = 0x20;
this.server = ".";
this.interface = null;
this.cursor = {};
this.current = {};
this.create = function() {
this.interface = GetObject("winmgmts:{impersonationLevel=impersonate}!\\\\.\\root\\cimv2");
this.interface = GetObject("winmgmts:{impersonationLevel=impersonate}!\\\\" + this.server + "\\root\\cimv2");
return this;
};
this.setServer = function(server) {
this.server = server;
return this;
};
this.execQuery = function(query) {
try {
var result = this.interface.ExecQuery(query, "WQL", wbemFlagReturnImmediately | wbemFlagForwardOnly);
this.cursor = new Enumerator(result);
} catch(e) {
} catch (e) {
console.error(e.message);
}
return this;