Update WMI.js

This commit is contained in:
Namhyeon Go 2020-11-15 05:49:28 +09:00
parent 65b048f7f3
commit 02c68cd034
2 changed files with 25 additions and 12 deletions

View File

@ -11,19 +11,19 @@ exports.require = global.require;
exports.createProcess = function(cmd) { exports.createProcess = function(cmd) {
var SW_HIDE = 0; var SW_HIDE = 0;
var si = WMI.setClass("Win32_ProcessStartup").create();
si.ShowWindow = SW_HIDE;
si.CreateFlags = 16777216;
si.X = si.Y = si.XSize = si.ySize = 1;
//wmi.Get("Win32_Process").Create(cmd, null, si, pid); //wmi.Get("Win32_Process").Create(cmd, null, si, pid);
var process = WMI.setClass("Win32_Process").setMethod("Create").setParameters({ return WMI.setClass("Win32_Process").setMethod("Create").setParameters({
"CommandLine": cmd, "CommandLine": cmd,
"CurrentDirectory": null, "CurrentDirectory": null,
"ProcessStartupInformation": si "ProcessStartupInformation": WMI.setClass("Win32_ProcessStartup").create()
}).execute(); .setAttribute("ShowWindow", SW_HIDE)
.setAttribute("CreateFlags", 16777216)
return process.get("ProcessID"); .setAttribute("X", 1)
.setAttribute("Y", 1)
.setAttribute("xSize", 1)
.setAttribute("ySize", 1)
.getInstance()
}).execute().get("ProcessID");
}; };
exports.getEnvString = function(envName) { exports.getEnvString = function(envName) {

View File

@ -6,20 +6,33 @@ var WMIClassObject = function() {
this.interface = (new WMIQueryObject()).interface; this.interface = (new WMIQueryObject()).interface;
this.class = null; this.class = null;
this.className = ""; this.className = "";
this.instance = null;
this.method = null; this.method = null;
this.methodName = ""; this.methodName = "";
this.inParams = {}; this.inParams = {};
this.outParams = {}; this.outParams = {};
// Instance
this.setClass = function(className) { this.setClass = function(className) {
this.className = className; this.className = className;
this.class = this.interface.Get(className); this.class = this.interface.Get(className);
return this; return this;
}; };
this.create = function() { this.create = function() {
var si = this.class.SpawnInstance_(); this.instance = this.class.SpawnInstance_();
return si; return this;
}; };
this.getAttribute = function(key) {
return this.instance[key];
};
this.setAttribute = function(key, value) {
this.instance[key] = value;
};
this.getInstance = function() {
return this.instance;
};
// Method
this.setMethod = function(methodName) { this.setMethod = function(methodName) {
this.methodName = methodName; this.methodName = methodName;
this.method = this.class.Methods_.Item(methodName); this.method = this.class.Methods_.Item(methodName);