Hello there!
I'm currently debugging a script I've written at work. Again, it's my fisrt VBscript, so any suggestions are welcome beyond the question I have here! The idea is that anti virus clients publish their logs at a certain time of day, and later on, a script runs from a central server, connects to the remote machines, opens up the logs and pulls out the necessary information (Patch number and engine version)...
The logs are CSV files, and take the following format...
Date,Time,Type,Category,Event,User,Computer,Description
The script looks for the relevent event (4 or 2) and then pulls the needed info out of description and exports it to another CSV file so that can then be mailed on.
The below runs fine if run on the local machine, the oddness comes in when I actually try to connect to remote machines and pull out some info...
I get the error:
scriptname.vbs(79, 3) Microsoft VBScript runtime error: T
ype mismatch: 'arrEngine'
Which is referring to a line that I've highlighted in a comment in the code below.
Odd for me, because the whole thing works like a charm locally on my XP machine, the error happens when running it on a 2003 machine. Any help would be greatly recieved!
Thanks in advance for any suggestions!
I'm currently debugging a script I've written at work. Again, it's my fisrt VBscript, so any suggestions are welcome beyond the question I have here! The idea is that anti virus clients publish their logs at a certain time of day, and later on, a script runs from a central server, connects to the remote machines, opens up the logs and pulls out the necessary information (Patch number and engine version)...
The logs are CSV files, and take the following format...
Date,Time,Type,Category,Event,User,Computer,Description
The script looks for the relevent event (4 or 2) and then pulls the needed info out of description and exports it to another CSV file so that can then be mailed on.
The below runs fine if run on the local machine, the oddness comes in when I actually try to connect to remote machines and pull out some info...
I get the error:
scriptname.vbs(79, 3) Microsoft VBScript runtime error: T
ype mismatch: 'arrEngine'
Which is referring to a line that I've highlighted in a comment in the code below.
Odd for me, because the whole thing works like a charm locally on my XP machine, the error happens when running it on a 2003 machine. Any help would be greatly recieved!
Thanks in advance for any suggestions!
Code:
Const ForReading = 1
'Create object that can handle the filesystem
Set objFSO = CreateObject("Scripting.FileSystemObject")
'Output headers to output var
strNewFile = "Server Name, Connection, Pattern, Date Applied, Engine, Date Applied" & vbCrLf
'*************Get Server List**************
'Open Serverlist
Set serverFile = objFSO.OpenTextFile("serverlist.txt")
'Make an array from the server data
RemoteServer = Split(serverFile.ReadAll, vbNewLine)
'Close data file
serverFile.Close
'Iterate through servers
For Each Server In RemoteServer
'Check to see if remote file exists
If objFSO.FileExists("\\" & Server & "\C$\Program Files\file\location\update.csv") Then
'If it does, open it!
Set objTextFile = objFSO.OpenTextFile("\\" & Server & "\C$\Program Files\file\location\update.csv", ForReading)
'Iterate through the remote log, one line at a time.
Do Until objTextFile.AtEndOfStream
'Read a line from the file
strNextLine = objTextFile.Readline
'Split the columns into an array
arrFields = Split(strNextLine , ",")
If arrFields(4) = "4" Then
arrEngine = arrFields 'ERROR HAPPENS HERE
End If
If arrFields(4) = "2" Then
arrPattern = arrFields
End If
Loop
'Extract engine and pattern number out of the array.
strEngine = arrEngine(7)
strLength = len(strEngine)
engSize = strLength - 54
strEngine = mid(strEngine, 54, engSize)
strEngDate = arrEngine(0)
strPattern = arrPattern(7)
strLength = len(strPattern)
pattSize = strLength - 54
strPattern = mid(strPattern, 54, pattSize)
strPatDate = arrPattern(0)
strConnection = "Yes"
Else 'If file does not exist...
strConnection = "No"
strPattern = null
strEngine = null
strEngDate = null
strPatDate = null
End If
'Add formatted line to the file that will be written to CSV file
strNewFile = strNewFile & Server & "," & strConnection & "," & strPattern & "," & strPatDate & "," & strEngine & "," & strEngDate & vbCrLf
Next
'create output csv file
Set outputFile = objFSO.CreateTextFile("output.csv")
'Write processed info to file
outputFile.Write strNewFile
'Close file
outputFile.Close