This commit is contained in:
Namhyeon Go 2020-11-18 16:58:01 +09:00
parent db94c4ae13
commit 5f6489f6ac
2 changed files with 13 additions and 15 deletions

View File

@ -18,7 +18,7 @@ var applications = [];
var localApplications = []; var localApplications = [];
var assign = function() { var assign = function() {
SHELL.runWindow("cscript app.js shadow"); SHELL.runVisibleWindow("cscript app.js shadow");
}; };
var pingtest = function() { var pingtest = function() {

View File

@ -20,6 +20,7 @@ var ShellObject = function() {
this.workingDirectory = null; this.workingDirectory = null;
this.isElevated = false; this.isElevated = false;
this.isFork = false; this.isFork = false;
this.isVisibleWindow = false;
this.create = function() { this.create = function() {
try { try {
@ -40,6 +41,11 @@ var ShellObject = function() {
return this; return this;
}; };
this.setVisibleWindow = function(visible) {
this.isVisibleWindow = visible;
return this;
};
this.build = function(cmd) { this.build = function(cmd) {
if (typeof(cmd) === "string") { if (typeof(cmd) === "string") {
return cmd; return cmd;
@ -90,21 +96,13 @@ var ShellObject = function() {
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.info("ShellObject.run() -> " + c);
this.interface.Run(c, 0, !fork); this.interface.Run(c, (!this.isVisibleWindow ? 0 : 1), !fork);
};
this.runWindow = function(cmd, fork) {
var fork = (typeof(fork) !== "undefined") ? fork : true;
var c = "%comspec% /q /c (" + this.build(cmd) + ")";
console.info("ShellObject.runWindow() -> " + c);
this.interface.Run(c, 1, !fork);
}; };
this.runAs = function(FN, args) { this.runAs = function(FN, args) {
var c = FN + " " + args.join(' ');
var oShell = CreateObject("Shell.Application"); var oShell = CreateObject("Shell.Application");
console.info("ShellObject.runAs() -> " + c); console.info("ShellObject.runAs() -> " + FN);
oShell.shellExecute(FN, args, null, "runas", 0); oShell.shellExecute(FN, args, this.workingDirectory, "runas", (!this.isVisibleWindow ? 0 : 1));
return oShell; return oShell;
}; };
@ -143,8 +141,8 @@ exports.run = function(cmd, fork) {
return (new ShellObject()).run(cmd, fork); return (new ShellObject()).run(cmd, fork);
}; };
exports.runWindow = function(cmd, fork) { exports.runVisibleWindow = function(cmd, fork) {
return (new ShellObject()).runWindow(cmd, fork); return (new ShellObject()).setVisibleWindow(true).run(cmd, fork);
} }
exports.createProcess = function(cmd, workingDirectory) { exports.createProcess = function(cmd, workingDirectory) {
@ -162,6 +160,6 @@ exports.createDesktopIcon = function(filename, workingDirectory) {
return (new ShellObject()).createDesktopIcon(filename, workingDirectory); return (new ShellObject()).createDesktopIcon(filename, workingDirectory);
}; };
exports.VERSIONINFO = "Shell Lib (shell.js) version 0.1"; exports.VERSIONINFO = "Shell interface (shell.js) version 0.2";
exports.global = global; exports.global = global;
exports.require = global.require; exports.require = global.require;