mirror of
https://github.com/gnh1201/welsonjs.git
synced 2025-02-11 17:34:58 +00:00
Update powershell.js
This commit is contained in:
parent
dedfbbefea
commit
37ce425a1c
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue
Block a user