How can I check the error conditions in a VBScript script?

John Savill

October 1, 2006

1 Min Read
ITPro Today logo in a gray background | ITPro Today

A. By default, a VBScript script will halt on an error. However, you can add the following line at the beginning of the script:

on error resume next

which will cause the script to continue executing even after encountering an error. When this line is in place, after running commands you can check for errors using the following logic:

if err.number<>0 then     wscript.echo err.number, err.description    err.Clearend if 

About the Author

Sign up for the ITPro Today newsletter
Stay on top of the IT universe with commentary, news analysis, how-to's, and tips delivered to your inbox daily.

You May Also Like