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,

If ScriptEngine.Current is undefined, you're using a relatively old version of ClearScript, and we recommend that you switch to the latest version.

In any case, try the following in a console application:
engine.Script.Quit = new Action(() => engine.Interrupt());
engine.AddHostType("Console", typeof(Console));

try {
    engine.Execute(@"
        call Console.WriteLine(""Before"")
        call Quit
        call Console.WriteLine(""After (shouldn't get here)"")
    ");
}
catch (ScriptInterruptedException) {
}
This code should work with older versions of ClearScript.

Thanks!

Viewing all articles
Browse latest Browse all 2297

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>