The on error statement allows you to somewhat control how the scripting engine handles errors in the scripts you write. It allows you to turn error handling on and off for the scripting engine so that you can handle them in your script.
The Statement essentially has two ways it is used. First to turn off the script engine error checking:
On Error Resume Next
The second is to turn it on, thereby allowing the script engine to stop execution of a script when an error is encountered. Like so:
On Error Goto 0
One word of caution, It is very tempting to simply place “On error resume next” in a complex script block and not worry about annoying hard to find errors. However, It is generally better to try to find the source of the errors since ignoring the errors can cause unintended consequences– or at the very least difficult to find issues in another piece of code.
In general, if you use On Error Resume Next you should always check for errors and handle them in your code somehow.