McAfee setup for XWall

with improved reliability

The McAfee update may fail on occasions. We had the problem occur on our XWall installation this past June. We were running the McAfee autoupdate process on our XWall server every hour. In talking to McAfee technical support, they recommended not running the autoupdate process this frequently. To get around this problem I wrote a vbs script to perform the dat update instead of replying on the McAfee's autoupdate process.

by Joe Gasper, a senior advisor on the Ceratec XWall Forum

I like to use the daily DATs (sometimes several per day) from McAfee for use with XWall (ePO manages the DATs for Exchange using the standard DATs). It keeps XWall's anti-virus skills bleeding edge, while Exchange runs with the "production" DATs. I get them from here:

I check that McAfee web page hourly to see if there's a new beta DAT out, then initiate a download only when there's been an update. This keeps the downloads to a minimum. I had been downloading the DATs every 4 hrs all the time for the last few months without problems, but Michael's setup got me to rewrite my code to be more net-friendly :-) Feel free to use at your own risk my code below (you'll need to install 2 free controls, one for unzipping, one for reading a web page).


'Author: Joe Gasper -
'Version: 1.10
'Purpose: Download NAI Daily Dat files from
'Uses free ActiveX control for unzipping:
' (or could use cli unzipper)

'Uses free AspTear for checking updated DATs:

Dim strRemoteFile 'Remote file to download, URL format.
Dim strLocalFile 'Local file path and name to save remote file to.

strLocalPath = "c:\xwall\av\"
strLocalFile = ""
strRemoteFile = ""

'Begin Main

If isNewFile Then
saveBinaryFile strLocalFile, getBinaryURL(strRemoteFile)
unZip strLocalPath, strLocalFile
End If

'End Main

Function getBinaryURL(URL)
Dim objHTTP
' Too many choices, one of these should work right?
Set objHTTP = CreateObject("WinHttp.WinHttpRequest.5.1")
' Set objHTTP = CreateObject("WinHttp.WinHttpRequest")
' Set objHTTP = CreateObject("Microsoft.XMLHTTP")
' Set objHTTP = CreateObject("MSXML2.ServerXMLHTTP")
objHTTP.Open "GET", URL, False
getBinaryURL = objHTTP.ResponseBody
End Function

Sub saveBinaryFile(FileName, ByteArray)
Const adTypeBinary = 1
Const adSaveCreateOverWrite = 2
Dim BinaryStream
Set BinaryStream = CreateObject("ADODB.Stream")
BinaryStream.Type = adTypeBinary
BinaryStream.Write ByteArray
BinaryStream.SaveToFile FileName, adSaveCreateOverWrite
End Sub

Sub unZip(FilePath, FileName)
Set objZip = CreateObject("XStandard.Zip")
objZip.UnPack FilePath & FileName, FilePath
Set objZip = Nothing
End Sub

Function isNewFile()
Dim strSiteCheck, objTear, strSiteHTML, intFindDate, dtmUpdated, strSearchText

strSiteCheck = ""
strSearchText = " PT"

Set objTear = CreateObject("SOFTWING.ASPtear")

On Error Resume Next
' URL, action, payload, username, password
strSiteHTML = objTear.Retrieve(strSiteCheck, 2, "", "", "")
dtmInstalled = CDate(getInstalledDATdate)
If Err.Number <> 0 Then
isNewFile = True 'fail-safe
intFindDate = InStr(1, strSiteHTML, strSearchText, vbBinaryCompare)
dtmUpdated = CDate(Trim(Mid(strSiteHTML, intFindDate - 16, 16)))
If dtmUpdated = dtmInstalled Then
isNewFile = False
isNewFile = True
End If
End If

Set objTear = Nothing
End Function

Function getInstalledDATdate
Const ForReading = 1, CreateIfNotExist = True
Dim fso, f, d, dtmFailSafe
On Error Resume Next
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.OpenTextFile("InstalledDATDate.txt", ForReading, CreateIfNotExist)
If NOT f.AtEndOfStream Then
d = CDate(f.ReadLine)
If IsDate(d) Then
getInstalledDATdate = CDate(d)
getInstalledDATdate = #1/1/2004 12:00# 'fail-safe
End If
getInstalledDATdate = #1/1/2004 12:00# 'fail-safe
End If
Set f = Nothing
End Function

Function setInstalledDATdate(dtmDate)
Const ForWriting = 2, CreateIfNotExist = True
Dim fso, f, d
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.OpenTextFile("InstalledDATDate.txt", ForWriting, CreateIfNotExist)
Set f = Nothing
End Function

Function logError
Const ForAppending = 8, CreateIfNotExist = True
Dim fso, f, d
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.OpenTextFile("DATupdateError.txt", ForAppending, CreateIfNotExist)
Set f = Nothing
End Function

'Code if you want to use a CLI unzipper:
Sub unZipFileCLI(zipFile)
Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.Run "c:\xwall\av\unzip.exe -oq " & zipFile, 0, true
End Sub