07-24-2023, 09:34 AM
### background
I have a `JScript` script running under `WSH`.
The script is fairly simple. It iterates over a list of strings, each string, a `JScript` itself, and run each "internal" script.
### Problem
It is possible that some "internal" script, may call [Quit method](
### Simple example
var strSomeScript = "WScript.Quit(1)";
var F = new Function(strSomeScript);
var exitCode = (F)();
WScript.Echo("Continue doing more things...");
the last line will not be executed since the "internal" script stops the execution.
### Question
If I have no control over the content of the "internal" scripts, how can I prevent them from breaking my main flow.
### Requirements
I need to run each "internal" script, wait for it to finish and store its exit code.
I have a `JScript` script running under `WSH`.
The script is fairly simple. It iterates over a list of strings, each string, a `JScript` itself, and run each "internal" script.
### Problem
It is possible that some "internal" script, may call [Quit method](
[To see links please register here]
). This causes the main script to stop, which is **not** desired.### Simple example
var strSomeScript = "WScript.Quit(1)";
var F = new Function(strSomeScript);
var exitCode = (F)();
WScript.Echo("Continue doing more things...");
the last line will not be executed since the "internal" script stops the execution.
### Question
If I have no control over the content of the "internal" scripts, how can I prevent them from breaking my main flow.
### Requirements
I need to run each "internal" script, wait for it to finish and store its exit code.