Suppress errors for the whole script

╄→гoц情女王★ 提交于 2019-12-01 04:41:48

You can do it - even without the OEG0 line - but you shouldn't, because the script will continue to execute lines i ... last, even if an error in line i-1 invalidates all your assumptions about necessary pre-conditions of the actions in those lines. Your strategy is comparable to driving with your eyes shut to avoid being dazzled by the headlights of other cars.

If you can't do locally resticted error handling for selected actions -

...
On Error Resume Next
  risky_action
  save Err
On Error GoTo 0
If ErrorOccurred Then
   something sensible
   If can't continue Then
      WScript.Quit 4711
   End If
End If
...

try to get away with

Sub Main()
  ... you 500 lines ...
End Sub 

On Error Resume Next
  Main
  If Err.Number Then
     WScript.Echo "aborted"
     WScript.Quit 4711
  End If

This approach makes sure that the lines after an error won't be executed.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!