Update powershell.js

This commit is contained in:
Namhyeon Go 2020-07-19 06:06:41 +09:00
parent dedfbbefea
commit 37ce425a1c

View File

@ -6,6 +6,17 @@ var scope = {
require: global.require
};
scope.addslashes = function(string) {
return string.replace(/\\/g, '\\\\').
replace(/\u0008/g, '\\b').
replace(/\t/g, '\\t').
replace(/\n/g, '\\n').
replace(/\f/g, '\\f').
replace(/\r/g, '\\r').
replace(/'/g, '\\\'').
replace(/"/g, '\\"');
}
scope.execScript = function(scriptName, args) {
var arguments = [
"powershell.exe",
@ -26,4 +37,20 @@ scope.execScript = function(scriptName, args) {
return SHELL.exec(arguments.join(' '));
};
scope.execCommand = function(command) {
var arguments = [
"powershell.exe",
"-NoProfile",
"-ExecutionPolicy",
"ByPass",
"-nologo"
"-Command",
"\"& {",
scope.addslashes(command),
"}\""
];
return SHELL.exec(arguments.join(' '));
};
return scope;