I am want to suppress all the errors that could appear in my VBS logon script.
Can I surround the WHOLE 500 lines script with :
On Error Resume Next
'[... whole script (~500 lines of code) ...]
On Error GoTo 0
1> /dev/null throw away stdout. 2> /dev/null throw away stderr. &> /dev/null throw away both stdout and stderr.
If you are looking to suppress or hide all the output of a bash shell script from Linux command line as well as from the crontab then you can simply redirect all the output to a file known as /dev/null . This file is known as Black Hole which will engulf everything you give without complaining.
Error action The ErrorAction switch lets you tell PowerShell what to do if the cmdlet produces an error. If your goal is to suppress an error message and make it seem as though nothing has happened, then the error action of choice is SilentlyContinue.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With