VB script with logging template
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
Dim objFSO, myLog, dt, dtformatted Const For_Writing = 2 Set objFSO = CreateObject("Scripting.FileSystemObject") Set myLog = objFSO.OpenTextFile("C:\temp\my.log", For_Writing, True) 'Main script writelog "yes it works now" myLog.Close Function LPad (str, pad, length) LPad = String(length - Len(str), pad) & str End Function Function WriteLog (str) dt = Now dtformatted = year(dt) & "-" & LPad(Month(dt), "0", 2) & "-" & LPad(Day(dt), "0", 2) & " " & LPad(Hour(dt), "0", 2) & ":" & LPad(Minute(dt), "0", 2) & ":" & LPad(Second(dt), "0", 2) myLog.WriteLine dtformatted & " ### " & str End Function |