mirror of
https://github.com/gnh1201/welsonjs.git
synced 2024-11-26 23:41:42 +00:00
44 lines
1.0 KiB
JavaScript
44 lines
1.0 KiB
JavaScript
////////////////////////////////////////////////////////////////////////
|
|
// Powershell API
|
|
///////////////////////////////////////////////////////////////////////
|
|
|
|
var SHELL = require("lib/shell");
|
|
|
|
exports.VERSIONINFO = "Powershell (powershell.js) version 0.1";
|
|
exports.global = global;
|
|
exports.require = global.require;
|
|
|
|
exports.execScript = function(scriptName, args) {
|
|
var cmd = [
|
|
"powershell.exe",
|
|
"-NoProfile",
|
|
"-ExecutionPolicy",
|
|
"ByPass",
|
|
"-nologo",
|
|
"-file",
|
|
scriptName + ".ps1"
|
|
];
|
|
|
|
if (typeof(cmd) !== "undefined") {
|
|
cmd = cmd.concat(args);
|
|
}
|
|
|
|
return SHELL.exec(cmd);
|
|
};
|
|
|
|
exports.execCommand = function(cmd) {
|
|
return SHELL.exec([
|
|
"powershell.exe",
|
|
"-NoProfile",
|
|
"-ExecutionPolicy",
|
|
"ByPass",
|
|
"-nologo",
|
|
"-Command",
|
|
"& {" + cmd + "}"
|
|
]);
|
|
};
|
|
|
|
exports.runAs = function(cmd) {
|
|
return exports.execCommand("Start-Process cmd \"/q /c " + SHELL.addslashes(SHELL.makeCmdLine(cmd)) + "\" -Verb RunAs");
|
|
};
|