Update WMI.js

This commit is contained in:
Namhyeon Go 2020-11-15 04:46:30 +09:00
parent d0c6cb89f2
commit 2aa60e0dcf
2 changed files with 11 additions and 12 deletions

8
app.js
View File

@ -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();

View File

@ -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) {