Quantcast
Channel: ClearScript
Viewing all articles
Browse latest Browse all 2297

New Post: How to exit the vbscript code at runtime

$
0
0
Hi Jaskaran,

The WScript.Quit method simply exits the process, and you can easily expose a similar API with ClearScript:
engine.Script.Quit = new Action<int>(Environment.Exit);
On the other hand, if you're looking for a way to terminate the current script without exiting the process, you can call ScriptEngine.Interrupt():
engine.Script.Quit = new Action(() => ScriptEngine.Current.Interrupt());
Note that doing so will generate a ScriptInterruptedException that you'll have to catch.

Another possibility might be to have your Quit API throw a custom exception. The problem there is that the script can disable error propagation via On Error.

Good luck!

Viewing all articles
Browse latest Browse all 2297

Latest Images

Trending Articles





Latest Images