mirror of
https://github.com/gnh1201/welsonjs.git
synced 2025-05-13 21:21:03 +00:00
Update WMI.js
This commit is contained in:
parent
1167c6ab84
commit
d0c6cb89f2
10
app.js
10
app.js
|
@ -99,15 +99,7 @@ if (typeof(CreateObject) !== "function") {
|
||||||
|
|
||||||
if (typeof(GetObject) !== "function") {
|
if (typeof(GetObject) !== "function") {
|
||||||
var GetObject = function(pathName, className) {
|
var GetObject = function(pathName, className) {
|
||||||
var paths = pathName.split("\\");
|
console.error("Not supported on this environment.");
|
||||||
if (paths[0].indexOf("winmgmts:") > -1) {
|
|
||||||
var objLocator = CreateObject("WbemScripting.SWbemLocator");
|
|
||||||
var strComputer = paths[2];
|
|
||||||
var strNamespace = paths.slice(3).join("\\");
|
|
||||||
return objLocator.ConnectServer(strComputer, strNamespace);
|
|
||||||
} else {
|
|
||||||
console.log("Not supported " + pathName);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
11
lib/wmi.js
11
lib/wmi.js
|
@ -12,7 +12,16 @@ var WMIObject = function() {
|
||||||
this.current = {};
|
this.current = {};
|
||||||
|
|
||||||
this.create = function() {
|
this.create = function() {
|
||||||
this.interface = GetObject("winmgmts:{impersonationLevel=impersonate}!\\\\" + this.server + "\\root\\cimv2");
|
try {
|
||||||
|
if (typeof(GetObject) === "function") {
|
||||||
|
this.interface = GetObject("winmgmts:{impersonationLevel=impersonate}!\\\\" + this.server + "\\root\\cimv2");
|
||||||
|
} else {
|
||||||
|
var objLocator = CreateObject("WbemScripting.SWbemLocator");
|
||||||
|
this.interface = objLocator.ConnectServer(this.server, "\\root\\cimv2");
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
console.error(e.message);
|
||||||
|
}
|
||||||
return this;
|
return this;
|
||||||
};
|
};
|
||||||
this.setServer = function(server) {
|
this.setServer = function(server) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user