Contact Info

Crumbtrail

ActiveXperts.com » Administration » VBScript Collection » Logs » Plain Text Logs

Plain Text Scripting

Read a Comma Separated Values Log
Read a Fixed Width Column Log


You can use any of the VBScript programs below in ActiveXperts Network Monitor. Click here for an explanation about how to include scripts in ActiveXperts Network Monitor.



Read a Comma Separated Values Log


Extracts the information in the DHCP Server log to individual fields and records.
Const ForReading = 1

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTextFile = objFSO.OpenTextFile("C:\Windows\System32\DHCP\" _
    & "DhcpSrvLog-Mon.log", ForReading)

Do While objTextFile.AtEndOfStream <> True
    If inStr(objtextFile.Readline, ",") Then
        arrDHCPRecord = split(objTextFile.Readline, ",")
        Wscript.Echo "Event ID: " & arrDHCPRecord(0)
        Wscript.Echo "Date: " & arrDHCPRecord(1)
        Wscript.Echo "Time: " & arrDHCPRecord(2)
        Wscript.Echo "Description: " & arrDHCPRecord(3)
        Wscript.Echo "IP Address: " & arrDHCPRecord(4)
        Wscript.Echo "Host Name: " & arrDHCPRecord(5)
        Wscript.Echo "MAC Address: " & arrDHCPRecord(6)
    Else
        objTextFile.Skipline
    End If
    i = i + 1
Loop
	

Read a Fixed Width Column Log


Extracts the information in the NetSetup log to individual fields and records.
Const ForReading = 1

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTextFile = objFSO.OpenTextFile("C:\Windows\Debug\Netsetup.log", _
    ForReading)

Do While objTextFile.AtEndOfStream <> True
    strLinetoParse = objTextFile.ReadLine
    dtmEventDate = Mid(strLinetoParse, 1, 6)
    dtmEventTime = Mid(strLinetoParse, 7, 9)
    strEventDescription = Mid(strLinetoParse, 16)
    Wscript.Echo "Date: " & dtmEventDate
    Wscript.Echo "Time: " & dtmEventTime
    Wscript.Echo "Description: " & strEventDescription & VbCrLf
Loop
objFSO.Close