mirror of
https://github.com/gnh1201/welsonjs.git
synced 2025-05-14 21:51:04 +00:00
Update shell.js
This commit is contained in:
parent
12be53ebb4
commit
1b4e885ea1
15
lib/shell.js
15
lib/shell.js
|
@ -36,7 +36,7 @@ var ShellObject = function() {
|
||||||
if (typeof(dirname) === "string") {
|
if (typeof(dirname) === "string") {
|
||||||
this.workingDirectory = dirname;
|
this.workingDirectory = dirname;
|
||||||
this.interface.CurrentDirectory = this.workingDirectory;
|
this.interface.CurrentDirectory = this.workingDirectory;
|
||||||
console.info("ShellObject.workingDirectory ->", this.workingDirectory);
|
console.log("ShellObject.workingDirectory ->", this.workingDirectory);
|
||||||
}
|
}
|
||||||
return this;
|
return this;
|
||||||
};
|
};
|
||||||
|
@ -67,7 +67,7 @@ var ShellObject = function() {
|
||||||
this.createProcess = function(cmd) {
|
this.createProcess = function(cmd) {
|
||||||
try {
|
try {
|
||||||
var c = this.build(cmd);
|
var c = this.build(cmd);
|
||||||
console.info("ShellObject.createProcess() ->", c);
|
console.log("ShellObject.createProcess() ->", c);
|
||||||
return this.interface.Exec(c);
|
return this.interface.Exec(c);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error("ShellObject.createProcess() ->", e.message);
|
console.error("ShellObject.createProcess() ->", e.message);
|
||||||
|
@ -84,7 +84,7 @@ var ShellObject = function() {
|
||||||
//c += " 2>&1";
|
//c += " 2>&1";
|
||||||
c += " 2> " + stdErrPath;
|
c += " 2> " + stdErrPath;
|
||||||
this.interface.Run(c, 0, true);
|
this.interface.Run(c, 0, true);
|
||||||
console.info("ShellObject.exec() ->", c);
|
console.log("ShellObject.exec() ->", c);
|
||||||
sleep(1);
|
sleep(1);
|
||||||
|
|
||||||
if (FILE.fileExists(stdOutPath)) {
|
if (FILE.fileExists(stdOutPath)) {
|
||||||
|
@ -97,6 +97,7 @@ var ShellObject = function() {
|
||||||
FILE.deleteFile(stdErrPath);
|
FILE.deleteFile(stdErrPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
console.log(c);
|
||||||
//console.log("[stdout] " + stdout);
|
//console.log("[stdout] " + stdout);
|
||||||
//console.log("[stderr] " + stderr);
|
//console.log("[stderr] " + stderr);
|
||||||
|
|
||||||
|
@ -106,14 +107,14 @@ var ShellObject = function() {
|
||||||
this.run = function(cmd, fork) {
|
this.run = function(cmd, fork) {
|
||||||
var fork = (typeof(fork) !== "undefined") ? fork : true;
|
var fork = (typeof(fork) !== "undefined") ? fork : true;
|
||||||
var c = "%comspec% /q /c (" + this.build(cmd) + ")";
|
var c = "%comspec% /q /c (" + this.build(cmd) + ")";
|
||||||
console.info("ShellObject.run() ->", c);
|
console.log("ShellObject.run() ->", c);
|
||||||
this.interface.Run(c, (!this.isVisibleWindow ? 0 : 1), !fork);
|
this.interface.Run(c, (!this.isVisibleWindow ? 0 : 1), !fork);
|
||||||
};
|
};
|
||||||
|
|
||||||
this.runAs = function(FN, args) {
|
this.runAs = function(FN, args) {
|
||||||
var oShell = CreateObject("Shell.Application");
|
var oShell = CreateObject("Shell.Application");
|
||||||
var _args = null;
|
var _args = null;
|
||||||
console.info("ShellObject.runAs() ->", FN);
|
console.log("ShellObject.runAs() ->", FN);
|
||||||
if (typeof(args) !== "undefined") {
|
if (typeof(args) !== "undefined") {
|
||||||
_args = args.join(' ');
|
_args = args.join(' ');
|
||||||
}
|
}
|
||||||
|
@ -145,7 +146,7 @@ var ShellObject = function() {
|
||||||
};
|
};
|
||||||
|
|
||||||
this.release = function() {
|
this.release = function() {
|
||||||
console.info("ShellObject.release() ->", this.currentDirectory);
|
console.log("ShellObject.release() ->", this.currentDirectory);
|
||||||
this.interface.CurrentDirectory = this.currentDirectory;
|
this.interface.CurrentDirectory = this.currentDirectory;
|
||||||
this.interface = null;
|
this.interface = null;
|
||||||
};
|
};
|
||||||
|
@ -175,7 +176,7 @@ exports.runVisibleWindow = function(cmd, fork) {
|
||||||
|
|
||||||
exports.createProcess = function(cmd, workingDirectory) {
|
exports.createProcess = function(cmd, workingDirectory) {
|
||||||
if (typeof(workingDirectory) !== "undefined") {
|
if (typeof(workingDirectory) !== "undefined") {
|
||||||
console.info("Working directory: " + workingDirectory);
|
console.log("Working directory: " + workingDirectory);
|
||||||
}
|
}
|
||||||
return (new ShellObject()).setWorkingDirectory(workingDirectory).createProcess(cmd);
|
return (new ShellObject()).setWorkingDirectory(workingDirectory).createProcess(cmd);
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue
Block a user