mirror of
https://github.com/gnh1201/welsonjs.git
synced 2025-05-15 06:01:04 +00:00
Update WMI.js
This commit is contained in:
parent
d0c6cb89f2
commit
2aa60e0dcf
6
app.js
6
app.js
|
@ -97,12 +97,6 @@ if (typeof(CreateObject) !== "function") {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
if (typeof(GetObject) !== "function") {
|
|
||||||
var GetObject = function(pathName, className) {
|
|
||||||
console.error("Not supported on this environment.");
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
function require(FN) {
|
function require(FN) {
|
||||||
var cache = require.__cache = require.__cache || {};
|
var cache = require.__cache = require.__cache || {};
|
||||||
if (FN.substr(FN.length - 3) !== '.js') FN += ".js";
|
if (FN.substr(FN.length - 3) !== '.js') FN += ".js";
|
||||||
|
|
15
lib/wmi.js
15
lib/wmi.js
|
@ -6,7 +6,8 @@ var WMIObject = function() {
|
||||||
var wbemFlagReturnImmediately = 0x10;
|
var wbemFlagReturnImmediately = 0x10;
|
||||||
var wbemFlagForwardOnly = 0x20;
|
var wbemFlagForwardOnly = 0x20;
|
||||||
|
|
||||||
this.server = ".";
|
this.computer = ".";
|
||||||
|
this.namespace = "root\\cimv2";
|
||||||
this.interface = null;
|
this.interface = null;
|
||||||
this.cursor = {};
|
this.cursor = {};
|
||||||
this.current = {};
|
this.current = {};
|
||||||
|
@ -14,18 +15,22 @@ var WMIObject = function() {
|
||||||
this.create = function() {
|
this.create = function() {
|
||||||
try {
|
try {
|
||||||
if (typeof(GetObject) === "function") {
|
if (typeof(GetObject) === "function") {
|
||||||
this.interface = GetObject("winmgmts:{impersonationLevel=impersonate}!\\\\" + this.server + "\\root\\cimv2");
|
this.interface = GetObject("winmgmts:{impersonationLevel=impersonate}!\\\\" + this.computer + "\\" + this.namespace);
|
||||||
} else {
|
} else {
|
||||||
var objLocator = CreateObject("WbemScripting.SWbemLocator");
|
var objLocator = CreateObject("WbemScripting.SWbemLocator");
|
||||||
this.interface = objLocator.ConnectServer(this.server, "\\root\\cimv2");
|
this.interface = objLocator.ConnectServer(this.computer, this.namespace);
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error(e.message);
|
console.error(e.message);
|
||||||
}
|
}
|
||||||
return this;
|
return this;
|
||||||
};
|
};
|
||||||
this.setServer = function(server) {
|
this.setComputer = function(computer) {
|
||||||
this.server = server;
|
this.computer = computer;
|
||||||
|
return this;
|
||||||
|
};
|
||||||
|
this.setNamespace = function(namespace) {
|
||||||
|
this.namespace = namespace;
|
||||||
return this;
|
return this;
|
||||||
};
|
};
|
||||||
this.execQuery = function(query) {
|
this.execQuery = function(query) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user