mirror of
https://github.com/gnh1201/welsonjs.git
synced 2025-03-11 16:35:13 +00:00
arguments
is reserved word. change to commandOptions
This commit is contained in:
parent
a98b1fcf4c
commit
daf2ae2571
|
@ -20,37 +20,37 @@ exports.addslashes = function(string) {
|
|||
};
|
||||
|
||||
exports.execScript = function(scriptName, args) {
|
||||
var arguments = [];
|
||||
var commandOptions = [];
|
||||
|
||||
arguments.push("powershell.exe");
|
||||
arguments.push("-NoProfile");
|
||||
arguments.push("-ExecutionPolicy");
|
||||
arguments.push("ByPass");
|
||||
arguments.push("-nologo")
|
||||
arguments.push("-file");
|
||||
arguments.push(scriptName + ".ps1");
|
||||
commandOptions.push("powershell.exe");
|
||||
commandOptions.push("-NoProfile");
|
||||
commandOptions.push("-ExecutionPolicy");
|
||||
commandOptions.push("ByPass");
|
||||
commandOptions.push("-nologo")
|
||||
commandOptions.push("-file");
|
||||
commandOptions.push(scriptName + ".ps1");
|
||||
|
||||
if(typeof(args) !== "undefined") {
|
||||
for(var i in args) {
|
||||
arguments.push(args[i]);
|
||||
commandOptions.push(args[i]);
|
||||
}
|
||||
}
|
||||
|
||||
return SHELL.exec(arguments.join(' '));
|
||||
return SHELL.exec(commandOptions.join(' '));
|
||||
};
|
||||
|
||||
exports.execCommand = function(command) {
|
||||
var arguments = [];
|
||||
var commandOptions = [];
|
||||
|
||||
arguments.push("powershell.exe");
|
||||
arguments.push("-NoProfile");
|
||||
arguments.push("-ExecutionPolicy");
|
||||
arguments.push("ByPass");
|
||||
arguments.push("-nologo")
|
||||
arguments.push("-Command");
|
||||
arguments.push("\"& {");
|
||||
arguments.push(exports.addslashes(command));
|
||||
arguments.push("}\"");
|
||||
commandOptions.push("powershell.exe");
|
||||
commandOptions.push("-NoProfile");
|
||||
commandOptions.push("-ExecutionPolicy");
|
||||
commandOptions.push("ByPass");
|
||||
commandOptions.push("-nologo")
|
||||
commandOptions.push("-Command");
|
||||
commandOptions.push("\"& {");
|
||||
commandOptions.push(exports.addslashes(command));
|
||||
commandOptions.push("}\"");
|
||||
|
||||
return SHELL.exec(arguments.join(' '));
|
||||
return SHELL.exec(commandOptions.join(' '));
|
||||
};
|
||||
|
|
35
uriloader.js
35
uriloader.js
|
@ -22,40 +22,47 @@ return {
|
|||
if(pos < 0) {
|
||||
console.log("Not vaild URI");
|
||||
} else {
|
||||
var queryString = uri.substring(pos + 4);
|
||||
var query = this.parseQuery(queryString);
|
||||
var application = query['application'];
|
||||
var argument = query['argument'];
|
||||
var filename;
|
||||
var commandOptions = [],
|
||||
queryString = uri.substring(pos + 4),
|
||||
query = this.parseQuery(queryString);
|
||||
|
||||
switch(application) {
|
||||
if(!query.application) {
|
||||
query.application = "";
|
||||
}
|
||||
|
||||
switch(query.application) {
|
||||
case "app":
|
||||
filename = "app.hta";
|
||||
commandOptions.push("app.hta");
|
||||
break;
|
||||
case "mscalc":
|
||||
filename = "calc";
|
||||
commandOptions.push("calc");
|
||||
break;
|
||||
case "msie":
|
||||
filename = "%PROGRAMFILES%\\Internet Explorer\\iexplore.exe";
|
||||
commandOptions.push("\"%PROGRAMFILES%\\Internet Explorer\\iexplore.exe\"");
|
||||
commandOptions.push("https://github.com/gnh1201/welsonjs");
|
||||
break;
|
||||
case "msexcel":
|
||||
filename = "%PROGRAMFILES%\\Microsoft Office\\Office15\\EXCEL.EXE";
|
||||
commandOptions.push("\"%PROGRAMFILES%\\Microsoft Office\\Office15\\EXCEL.EXE\"");
|
||||
break;
|
||||
case "mspowerpoint":
|
||||
filename = "%PROGRAMFILES%\\Microsoft Office\\Office15\\POWERPNT.EXE";
|
||||
commandOptions.push("\"%PROGRAMFILES%\\Microsoft Office\\Office15\\POWERPNT.EXE\"");
|
||||
break;
|
||||
case "msword":
|
||||
filename = "%PROGRAMFILES%\\Microsoft Office\\Office15\\WINWORD.EXE";
|
||||
commandOptions.push("\"%PROGRAMFILES%\\Microsoft Office\\Office15\\WINWORD.EXE\"");
|
||||
break;
|
||||
case "msaccess":
|
||||
filename = "%PROGRAMFILES%\\Microsoft Office\\Office15\\MSACCESS.EXE";
|
||||
commandOptions.push("\"%PROGRAMFILES%\\Microsoft Office\\Office15\\MSACCESS.EXE\"");
|
||||
break;
|
||||
dafault:
|
||||
console.log("Unknown application");
|
||||
break;
|
||||
}
|
||||
|
||||
SHELL.run("\"" + filename + "\"" + " " + argument);
|
||||
if(typeof(query.argument) !== "undefined") {
|
||||
commandOptions.push(query.argument);
|
||||
}
|
||||
|
||||
SHELL.run(commandOptions.join(' '));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user