Update powershell.js

This commit is contained in:
Namhyeon Go 2023-03-10 11:43:35 +09:00 committed by GitHub
parent aed2ab6e04
commit 401cb4296e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -68,21 +68,19 @@ var PowershellObject = function() {
return this; return this;
}; };
this.exec = function(args) { this.build = function(args) {
if (this.execType != "ps1") { if (this.execType != "ps1") {
console.warn("The execType is not set 'ps1'. Will be forward it to the default shell."); console.warn("The execType is not set 'ps1'. Will be forward it to the default shell.");
SHELL.exec(this.target); return SHELL.build(this.target);
return;
} }
// default arguments
var cmd = [ var cmd = [
"powershell.exe", "powershell.exe",
"-NoProfile", "-NoProfile",
"-ExecutionPolicy", "-ExecutionPolicy",
"ByPass", "ByPass",
"-nologo" "-nologo"
]; ]; // default arguments
switch (this.dataType) { switch (this.dataType) {
case 3: // dataType: URL(3)\ case 3: // dataType: URL(3)\
@ -115,16 +113,15 @@ var PowershellObject = function() {
cmd = cmd.concat(args); cmd = cmd.concat(args);
} }
return SHELL.exec(cmd); return cmd;
}; };
this.runAs = function() { this.exec = function(args) {
if (this.execType != "ps1") { return SHELL.exec(this.build(args));
console.warn("The execType is not set 'ps1'. Will be forward it to the default shell."); };
return this.exec("Start-Process cmd \"/q /c " + SHELL.addslashes(SHELL.build(this.target)) + "\" -Verb RunAs");
} else { this.runAs = function(args) {
return this.exec("Start-Process cmd \"/q /c " + SHELL.addslashes(SHELL.build(cmd)) + "\" -Verb RunAs"); return this.exec("Start-Process cmd \"/q /c " + SHELL.addslashes(this.build(args)) + "\" -Verb RunAs");
}
}; };
} }