diff --git a/app.js b/app.js index 59c03ef..b604243 100644 --- a/app.js +++ b/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) { var cache = require.__cache = require.__cache || {}; if (FN.substr(FN.length - 3) !== '.js') FN += ".js"; @@ -243,7 +237,7 @@ require("app/assets/js/es6-sham-0.35.5.min"); // Babel-core browser-polyfill require("app/assets/js/babel-core-browser-polyfill-5.8.38.min"); -// dive into entrypoint +// dive into entrypoint function main() { if (typeof(window) === "undefined") { init_console(); diff --git a/lib/wmi.js b/lib/wmi.js index fe03ca7..b5f776a 100644 --- a/lib/wmi.js +++ b/lib/wmi.js @@ -6,7 +6,8 @@ var WMIObject = function() { var wbemFlagReturnImmediately = 0x10; var wbemFlagForwardOnly = 0x20; - this.server = "."; + this.computer = "."; + this.namespace = "root\\cimv2"; this.interface = null; this.cursor = {}; this.current = {}; @@ -14,18 +15,22 @@ var WMIObject = function() { this.create = function() { try { 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 { var objLocator = CreateObject("WbemScripting.SWbemLocator"); - this.interface = objLocator.ConnectServer(this.server, "\\root\\cimv2"); + this.interface = objLocator.ConnectServer(this.computer, this.namespace); } } catch (e) { console.error(e.message); } return this; }; - this.setServer = function(server) { - this.server = server; + this.setComputer = function(computer) { + this.computer = computer; + return this; + }; + this.setNamespace = function(namespace) { + this.namespace = namespace; return this; }; this.execQuery = function(query) {