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

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
end if 
Hide comments


  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.