mirror of
https://github.com/gnh1201/welsonjs.git
synced 2025-05-12 12:41:04 +00:00
Update powershell.js
This commit is contained in:
parent
42f971ab07
commit
4867faab16
|
@ -1,14 +1,78 @@
|
||||||
////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////
|
||||||
// Powershell API
|
// Powershell Interface API
|
||||||
///////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
var SHELL = require("lib/shell");
|
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) {
|
// new powershell interface
|
||||||
|
|
||||||
|
function PowershellInterface() {
|
||||||
|
this.type = -1;
|
||||||
|
this.target = null;
|
||||||
|
|
||||||
|
this.load = function(script) {
|
||||||
|
this.target = script;
|
||||||
|
this.type = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
this.loadFile = function(filename) {
|
||||||
|
this.target = filename;
|
||||||
|
this.type = 1;
|
||||||
|
};
|
||||||
|
|
||||||
|
this.loadRemoteUrl = function(url) {
|
||||||
|
this.target = url;
|
||||||
|
this.type = 2;
|
||||||
|
};
|
||||||
|
|
||||||
|
// For example:
|
||||||
|
// file:C:\\a\\b\\c
|
||||||
|
// http://
|
||||||
|
// https://
|
||||||
|
// data:text/plain;base64,SGVsbG8sIFdvcmxkIQ==
|
||||||
|
this.loadUri = function(uri) {
|
||||||
|
var pos = uri.indexOf(':');
|
||||||
|
var scheme = (pos < 0 ? '' : url.substring(0, pos));
|
||||||
|
var target = (pos < 0 ? uri : url.substring(pos + 1));
|
||||||
|
|
||||||
|
switch (scheme) {
|
||||||
|
case 'http':
|
||||||
|
case 'https':
|
||||||
|
this.loadRemoteUrl(target);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'file':
|
||||||
|
this.load(target);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
this.exec = function() {
|
||||||
|
switch (this.type) {
|
||||||
|
case 2:
|
||||||
|
// todo
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 1:
|
||||||
|
// todo
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 0:
|
||||||
|
// todo
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
function execScript(scriptName, args) {
|
||||||
var cmd = [
|
var cmd = [
|
||||||
"powershell.exe",
|
"powershell.exe",
|
||||||
"-NoProfile",
|
"-NoProfile",
|
||||||
|
@ -26,7 +90,7 @@ exports.execScript = function(scriptName, args) {
|
||||||
return SHELL.exec(cmd);
|
return SHELL.exec(cmd);
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.execCommand = function(cmd) {
|
function execCommand(cmd) {
|
||||||
return SHELL.exec([
|
return SHELL.exec([
|
||||||
"powershell.exe",
|
"powershell.exe",
|
||||||
"-NoProfile",
|
"-NoProfile",
|
||||||
|
@ -38,6 +102,15 @@ exports.execCommand = function(cmd) {
|
||||||
]);
|
]);
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.runAs = function(cmd) {
|
function runAs(cmd) {
|
||||||
return exports.execCommand("Start-Process cmd \"/q /c " + SHELL.addslashes(SHELL.makeCmdLine(cmd)) + "\" -Verb RunAs");
|
return execCommand("Start-Process cmd \"/q /c " + SHELL.addslashes(SHELL.makeCmdLine(cmd)) + "\" -Verb RunAs");
|
||||||
};
|
};
|
||||||
|
|
||||||
|
exports.execScript = execScript;
|
||||||
|
exports.execCommand = execCommand;
|
||||||
|
exports.runAs = runAs;
|
||||||
|
|
||||||
|
exports.VERSIONINFO = "Powershell (powershell.js) version 0.1.1";
|
||||||
|
exports.AUTHOR = "abuse@catswords.net";
|
||||||
|
exports.global = global;
|
||||||
|
exports.require = global.require;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user