Dim $URL,$Link,$RC,$Page,$Server,$File,$Download,$Target,$Wait,$Servers1,$Servers2,$FileSize
$URL='http://www.sarc.com/avcenter/download/pages/US-SAVCE.html'
$Link='http://definitions.symantec.com/defs/xdb/'
$RC=readHTML($URL)
$File=InStr($RC,$Link)
$File=SubStr($RC,$File+41,12)
$Download = $Link + $File
$Target='C:\DOWNLOAD\'
$Servers1='AV01','AV02','AV03','AV04'
$Servers2='D09','D17'
? 'Downloading ' + $File + ' Please wait...'
If FTPget($Download,$Target+$File)
? 'Error occured: ' + @ERROR + ' ' + @SERROR
Else
? 'Download complete... File saved in ' + $Target + ' as ' + $File
$FileSize = GetFileSize($Target+$File)
If $FileSize >14000000
? 'Ready to update AntiVirus Defs'
? 'File size downloaded was: ' + $FileSize
For Each $Server In $Servers1
Copy $Target+$File '\\'+$Server+'\c$\PROGRA~1\SAV'
? 'Copying to ' + $Server +'... ' + @ERROR + ' ' + @SERROR
Next
For Each $Server In $Servers2
Copy $Target+$File '\\'+$Server+'\c$\PROGRA~1\NAV'
? 'Copying to ' + $Server +'... ' + @ERROR + ' ' + @SERROR
Next
; This line archives the definition files to AV01 for reference
MOVE $Target+$File '\\av01\c$\XDB\OLDXDB'
? 'Moving xdb file to AV01 archive ' +@ERROR + ' ' + @SERROR
? 'Definition updates completed...'
? 'Please press a key to continue...'
Else
? 'The file size appears to be too small. Update aborted, please try later...'
? 'File size was: ' + $FileSize
EndIf
?? 'Press a key to continue...'
GET $Wait
EndIf
Function readHTML($page)
Dim $obj
$obj=createobject("microsoft.xmlhttp")
$obj.open("get",$page,not 1)
$obj.send
$readHTML=$obj.responsebody
EndFunction
Function FTPget($sURL, $sTargetFile, optional $sUser, optional $sPass)
Dim $oFTP, $oStream
$sUser=""+$sUser
$oFTP = CreateObject("Microsoft.XMLHTTP")
if @error $ftpget=1 exit 1 endif
$oStream = CreateObject("ADODB.Stream")
if @error $ftpget=2 exit 2 endif
if $sUser
$oFTP.Open("GET", $sURL, not 1, $sUser, $sPass)
else
$oFTP.Open("GET", $sURL, not 1)
endif
if @error $ftpget=3 exit 3 endif
$oFTP.Send
$oStream.Type = 1
$oStream.Mode = 3
$oStream.open
$oStream.Write($oFTP.responseBody)
if @error $ftpget=4 exit 4 endif
$oStream.SaveToFile($sTargetFile, 2)
if @error $ftpget=5 exit 5 endif
$oStream.Close
EndFunction