capture any error in VBScript?

Posted by JoelFan on Stack Overflow See other posts from Stack Overflow or by JoelFan
Published on 2010-05-28T14:08:38Z Indexed on 2010/05/28 14:12 UTC
Read the original article Hit count: 465

Filed under:
|

I have a batch file that calls a VBScript (.vbs) program. After calling it, my batch script checks errorlevel to see if the .vbs program failed. I can signal failure with an exit code in the .vbs program with WScript.Quit(1).

However, I can only do that explicitly. If some unexpected run-time error happens, the .vbs quits with an error dialog box, however the exit code is zero so my batch file thinks it suceeded! How can I change that behavior?

And if you are thinking of saying, use on error goto, don't bother... that syntax is available in regular VB, but not in VBScript.

© Stack Overflow or respective owner

Related posts about vbscript

Related posts about batch-file