07-24-2023, 12:32 AM
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 expected`WScript.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
1. How do I activate `s1.js` (internally in `s2.js`) and pass CLI params to it?
2. How do `s1.js` can distinguish between the two different ways of running it and read its arguments properly?
var objArgs = WScript.Arguments;
WScript.Echo(objArgs.length)
when `s1.js` is run using [WSH](
[To see links please register here]
)I get the expected`WScript.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
1. How do I activate `s1.js` (internally in `s2.js`) and pass CLI params to it?
2. How do `s1.js` can distinguish between the two different ways of running it and read its arguments properly?