So I have my JScript
script s1.js
var objArgs = WScript.Arguments;
WScript.Echo(objArgs.length)
when s1.js
is run using WSH
I get the expectedWScript.Arguments
.
It gets tricky however when I run s1.js
internally. Say I have another script s2.js
:
var F = new Function(strScript); // strScript is the content of s1.js
(F)("test");
When running s2.js
, with whatever CLI argument, var objArgs = WScript.Arguments
defined in s1.js
get the same arguments I passed to s2.js
.
This does not surprise me since I assume var objArgs = WScript.Arguments
is global and set by WSH
.
Question
- How do I activate
s1.js
(internally ins2.js
) and pass CLI params to it? - How do
s1.js
can distinguish between the two different ways of running it and read its arguments properly?