Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Logging

Status
Not open for further replies.

roywills

Technical User
Feb 18, 2008
6
US
ok, the window that pops up when there i an issue with your vbscript, is there a way to capture this toe the event log as an error?

Basically, i want to know if the script has any issues running and since i get alerted on errors in event log that would be ideal.
 
...code
On Error Resume Next
...code that might generate error
' write to event log
' Err.Number will give you the error number
' Err.Description will give you the description
On Error Goto 0
...code

--------------------------------------------------------------------------------
dm4ever
My philosophy: K.I.S.S - Keep It Simple Stupid
 
Writing to the local event log:

Code:
Const EVENT_SUCCESS = 0

Set objShell = Wscript.CreateObject("Wscript.Shell")

objShell.LogEvent EVENT_SUCCESS, _
    "My application successfully installed."

I hope you find this post helpful.

Regards,

Mark

Check out my scripting solutions at
Work SMARTER not HARDER. The Spider's Parlor's Admin Script Pack is a collection of Administrative scripts designed to make IT Administration easier! Save time, get more work done, get the Admin Script Pack.
 
if you can accept that all you code potentially can cause an error (runtime, blackbox thinking) then use the following boiler plate

Option Explicit
On Error Resume Next
Dim intError
intError = 0
Call Main()
If intError <> 0 Then
WScript.Quit intError
Else
WScript.Quit Err.Number
End If

Sub Main()
...on error resume next globally does
...not explicitly affect me


<dm4ever>
...code
On Error Resume Next
...code that might generate error
' write to event log
' Err.Number will give you the error number
' Err.Description will give you the description
On Error Goto 0
...code

End Sub

FuncXYZ

ClassXYZ
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top