Useful Error Handling And Logging In Script
(Page 1 of 3 )
Here is a couple of functions that are useful when debugging using Windows Scripting Host files. Notice in every function, ON ERROR RESUME NEXT and ERR.CLEAR is called. When using WSH or any script language, the rich debugging environment isn't available. Being able to debug your scripts and continue to the completion is a real challenge.
This technique has been useful in several hundred line script files that I've done. Notice in Function SAMPLE, 1 - this will log to a file on the c:\TrackingLog.txt, 2 and if there are any errors inside the function, all errors will Log right after what function was called also to the c:\trackingLog.txt. You can add whatever functionality you like to the Error Handler. This has been useful to me anyway! Any questions give me a shout!
Put these as global functions at the top of your windows scripting host
Set WshShell
= WScript.CreateObject("WScript.Shell") Set WshNetwork = WScript.CreateObject("Wscript.Network") Set FSO = CreateObject("Scripting.FileSystemObject") Function Sample() On Error Resume Next Err.Clear AddToLog('-Starting the Sample Function') ....rest of the code. End Function Write to a Text file
Next: Logging To A Text File >>
More ASP Articles
More By Steve Schofield