【发布时间】:2015-08-17 12:10:05
【问题描述】:
所以我有我的JScript 脚本s1.js
var objArgs = WScript.Arguments;
WScript.Echo(objArgs.length)
当s1.js 使用WSH 运行时
我得到了预期的WScript.Arguments。
但是当我在内部运行s1.js 时,它变得很棘手。假设我有另一个脚本s2.js:
var F = new Function(strScript); // strScript is the content of s1.js
(F)("test");
当运行s2.js 时,使用任何CLI 参数,s1.js 中定义的var objArgs = WScript.Arguments 得到与我传递给s2.js 相同的参数。
这并不让我感到惊讶,因为我假设 var objArgs = WScript.Arguments 是全局的并由 WSH 设置。
问题
- 如何激活
s1.js(在s2.js内部)并将CLI 参数传递给它? -
s1.js如何区分两种不同的运行方式并正确读取其参数?
【问题讨论】:
标签: javascript command-line-interface jscript wsh