mirror of
https://github.com/gnh1201/welsonjs.git
synced 2025-02-06 15:04:58 +00:00
Update WMI.js
This commit is contained in:
parent
65b048f7f3
commit
02c68cd034
|
@ -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) {
|
||||
|
|
17
lib/wmi.js
17
lib/wmi.js
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue
Block a user