VBScript Example

' Disable host error handling. Run time errors are handled by the script.
On Error Resume Next
'
' Declare variables
Dim objShell 'Used for instantiating the WshShell object model.
'
' Your script actions here.
'
' Check for errors.
'
If Err Then
'
' There was an error somewhere in the script.
' Write the error to the application event log.
' The event will have a source of WSH and an event number of 1.
'
objShell.LogEvent 1, Err.Number & VBLF & Err.source & VBLF & Err.Description
'
' Clean up.
'
Set objShell = nothing
'
' Exit using the error code.
'
WScript.Quit (Err.Number)
'
End If

'Clean up.
'
Set objShell = nothing
'
'Exit Gracefully.
'
WScript.Quit (0)
On Error GoTo 0
Default Environment