2020-12-10 02:27:05 +00:00
|
|
|
if (!Array.prototype.map) {
|
|
|
|
Array.prototype.map = function(fn) {
|
|
|
|
var rv = [];
|
|
|
|
for (var i = 0; i < this.length; i++)
|
|
|
|
rv.push(fn(this[i]));
|
|
|
|
return rv;
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2020-12-08 06:43:59 +00:00
|
|
|
function main() {
|
2020-12-10 02:27:05 +00:00
|
|
|
var args = [];
|
|
|
|
var argl = WScript.arguments.length;
|
|
|
|
for (var i = 0; i < argl; i++) {
|
|
|
|
args.push(WScript.arguments(i));
|
|
|
|
}
|
|
|
|
|
|
|
|
var objShell = WScript.CreateObject("WScript.Shell");
|
|
|
|
objShell.Run(build(args), 0, true);
|
2020-12-08 06:43:59 +00:00
|
|
|
}
|
|
|
|
|
2020-12-10 02:27:05 +00:00
|
|
|
function build(cmd) {
|
|
|
|
if (typeof(cmd) === "string") {
|
|
|
|
return cmd;
|
|
|
|
} else if (typeof(cmd) === "object") {
|
|
|
|
return cmd.map(function(s) {
|
|
|
|
var regex = /[ "]/g;
|
|
|
|
if (!regex.test(s)) {
|
|
|
|
return s;
|
|
|
|
} else {
|
|
|
|
return "\"" + addslashes(s) + "\"";
|
|
|
|
}
|
|
|
|
}).join(' ');
|
|
|
|
} else {
|
|
|
|
return "";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function addslashes(s) {
|
|
|
|
return s.toString().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, '\\"');
|
|
|
|
};
|
|
|
|
|
2020-12-08 06:43:59 +00:00
|
|
|
main();
|