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) {
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);
var process = WMI.setClass("Win32_Process").setMethod("Create").setParameters({
return WMI.setClass("Win32_Process").setMethod("Create").setParameters({
"CommandLine": cmd,
"CurrentDirectory": null,
"ProcessStartupInformation": si
}).execute();
return process.get("ProcessID");
"ProcessStartupInformation": WMI.setClass("Win32_ProcessStartup").create()
.setAttribute("ShowWindow", SW_HIDE)
.setAttribute("CreateFlags", 16777216)
.setAttribute("X", 1)
.setAttribute("Y", 1)
.setAttribute("xSize", 1)
.setAttribute("ySize", 1)
.getInstance()
}).execute().get("ProcessID");
};
exports.getEnvString = function(envName) {

View File

@ -6,20 +6,33 @@ var WMIClassObject = function() {
this.interface = (new WMIQueryObject()).interface;
this.class = null;
this.className = "";
this.instance = null;
this.method = null;
this.methodName = "";
this.inParams = {};
this.outParams = {};
// Instance
this.setClass = function(className) {
this.className = className;
this.class = this.interface.Get(className);
return this;
};
this.create = function() {
var si = this.class.SpawnInstance_();
return si;
this.instance = this.class.SpawnInstance_();
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.methodName = methodName;
this.method = this.class.Methods_.Item(methodName);