Hallo,
ich habe da ein kleines Skript geschrieben, dass die aktuelle SDATxxxx.exe von der McAfee Seite herunterlädt.
Ich denke da gibt es noch ordentlich Verbesserungsmöglichkeiten, z. B.
- Code von Bugs befreien
- hinzufügen weiterer Kommandozeilenparameter, damit eine INI nicht unbedingt nötig ist
- Errorhandling
- vernünftiges Logging
- vollständig unbeaufsichtigter Modus, damit man es auch per Scheduler (oder AT-Job) laufen lasse kann
- etc.
Vielleicht kann es ja jemand hier gebrauchen...
Spoiler anzeigen
;===============================================================================
;
; Description: Download of current SDATxxxx.exe files from McAfee page
; via HTTP (FTP is not allowed in some companies...)
;
; Author(s): ahe
; Version: 1.0.0.0
; Date: 26.06.2009
;
; Filename: McAfee_SDAT_Download.au3
; EXE name: McAfee_SDAT_Download.exe
;
;===============================================================================
; The script download the update.ini file from McAfee site, scan the entry for SDATxxxx.exe version
; and download the grabbed exe.
; In INI file CONF_SDAT_UPD.ini all specific pathes are stored, if McAfee changed something, you can
; change the entries too.
;===============================================================================
; Parameters from INI file:
; $update_site_url Path to update.ini on download page
; $sdat_url Base path to sdatxxxx.exe
; $update_ini_file Local store path to INI file
; $dest_sdat_path Local store path for sdatxxxx.exe
$INI = @ScriptDir & "\CONF_SDAT_UPD.ini"
[/autoit] [autoit][/autoit] [autoit]$INIFILE= 'CONV_SDAT_UPD.INI - example:' & @CRLF & @CRLF
$INIFILE= $INIFILE & '________________________________________________________________________________' & @CRLF
$INIFILE= $INIFILE & '[SDATURL]'& @CRLF
$INIFILE= $INIFILE & '; Path to update.ini on download page'& @CRLF
$INIFILE= $INIFILE & 'UPDATE_INI_URL="http://download.nai.com/products/datfiles/4.x/nai/update.ini"' & @CRLF
$INIFILE= $INIFILE & '; Base path to sdatxxxx.exe'& @CRLF
$INIFILE= $INIFILE & 'SDAT_URL="http://download.nai.com/products/licensed/superdat/english/intel/"'
$INIFILE= $INIFILE & '[SDATPATH]'& @CRLF
$INIFILE= $INIFILE & '; Local store path to INI file'& @CRLF
$INIFILE= $INIFILE & 'UPDATE_INI_PATH="c:\temp\nai\update.ini"'& @CRLF
$INIFILE= $INIFILE & '; Local store path for sdatxxxx.exe'& @CRLF
$INIFILE= $INIFILE & 'DEST_SDAT_PATH="c:\temp\nai"'& @CRLF
$INIFILE= $INIFILE & '________________________________________________________________________________' & @CRLF
$helpmsg = "Correct installation parameters:" & @CRLF
$helpmsg = $helpmsg & @TAB & "No parameter and no ini config file!" & @TAB & "The embedded values are used... (s. switch -e or /e)" & @CRLF
$helpmsg = $helpmsg & @TAB & "-INI YES " & @TAB & @TAB & "Use SDAT_UPD.ini in current directory to find the path to SDATxxxx.exe" & @CRLF
$helpmsg = $helpmsg & @TAB & "-INI NO " & @TAB & @TAB & "Search SDATxxxx.exe in standard path" & @CRLF
$helpmsg = $helpmsg & @TAB & "-PATH <path> " & @TAB & "Use the given path in the brackets <> to search SDATxxxx.exe" & @CRLF
$helpmsg = $helpmsg & @TAB & "-i or /i" & @TAB & "Overview about a correct CONF_SDAT_UPD.INI file." & @CRLF & @CRLF
$helpmsg = $helpmsg & @TAB & "This help: ?, -?, /?, h, -h, /h"
$helpmsg2 = "List embedded parameters:" & @CRLF
$helpmsg2 = $helpmsg2 & @TAB & "Path to update.ini on download page:" & @TAB & 'UPDATE_INI_URL="http://download.nai.com/products/datfiles/4.x/nai/update.ini"' & @CRLF
$helpmsg2 = $helpmsg2 & @TAB & "Base path to SDATxxxx.exe:" & @TAB & @TAB & 'SDAT_URL="http://download.nai.com/products/licensed/superdat/english/intel/"' & @CRLF
$helpmsg2 = $helpmsg2 & @TAB & "Local store path to INI file:" & @TAB & @TAB & 'UPDATE_INI_PATH="c:\temp\nai\update.ini"' & @CRLF
$helpmsg2 = $helpmsg2 & @TAB & "Local store path for SDATxxxx.exe:" & @TAB & 'DEST_SDAT_PATH="c:\temp\nai"' & @CRLF & @CRLF
$helpmsg2 = $helpmsg2 & @TAB & @TAB & "Help: ?, -?, /?, h, -h, /h"
if $CmdLine[0]=0 then
if FileExists($INI) Then
$update_site_url = IniRead($INI, "SDATURL", "UPDATE_INI_URL","NotFound")
$sdat_url = IniRead($INI, "SDATURL", "SDAT_URL","NotFound")
$dest_sdat_path = IniRead($INI, "SDATPATH", "DEST_SDAT_PATH","NotFound")
$update_ini_file = IniRead($INI, "SDATPATH", "UPDATE_INI_PATH","NotFound")
if $update_site_url="NotFound" or $sdat_url="NotFound" or $dest_sdat_path="NotFound" or $update_ini_file="NotFound" Then
MsgBox(0,"Error", "Not all entries in update.ini exist! Check values in CONF_SDAT_UPD.ini! "& @CRLF & @CRLF & $INIFILE)
Exit 90
EndIf
Else
; use standard parameters, could be quite old...
$update_site_url="http://download.nai.com/products/datfiles/4.x/nai/update.ini"
$sdat_url="http://download.nai.com/products/licensed/superdat/english/intel/"
$update_ini_file="c:\temp\nai\update.ini"
$dest_sdat_path="c:\temp\nai"
EndIf
Else
if $CmdLine[0]>0 then
Select
Case $CmdLine[1]="?" or $CmdLine[1]="-?" or $CmdLine[1]="/?" or $CmdLine[1]="h" or $CmdLine[1]="-h"or $CmdLine[1]="/h"
MsgBox(0, "Installation parameter", $helpmsg)
Exit 10
case StringUpper($CmdLine[1])="-E" or StringUpper($CmdLine[1])="/E"
MsgBox(0, "Installation parameter", $helpmsg2)
Exit 10
case StringUpper($CmdLine[1])="-I" or StringUpper($CmdLine[1])="/I"
MsgBox(0, "INI configuration", $INIFILE)
Exit 10
;Case StringUpper($CmdLine[1])="UPDATE_INI_URL" ; Command line or not Command line that's here the question...
Case Else
exit
EndSelect
EndIf
EndIf
;$update_site_url="http://download.nai.com/products/datfiles/4.x/nai/update.ini"
if $update_ini_file = "NotFound" Then
$update_ini_file=@TempDir & "\nai\update.ini"
EndIf
if $dest_sdat_path = "NotFound" Then
$dest_sdat_path=@TempDir & "\nai"
EndIf
; check if directory for update.ini exist and if update.ini exist delete it...
if FileExists($dest_sdat_path) <> 1 then
DirCreate($dest_sdat_path)
Else
if FileExists($dest_sdat_path &"\update.ini") then FileDelete($dest_sdat_path &"\update.ini")
EndIf
; download standard update.ini from McAfee page and save it in $update_ini_file
InetGet($update_site_url, $update_ini_file, 1, 1)
; wait a bit, otherwise IniRead won't find a update.ini to read...
Sleep(5000)
; get name of current SDATxxxx.exe from update.ini
$SDAT_name=IniRead($update_ini_file, "SuperDat-IA32", "FileName", "NotFound")
If $SDAT_name="NotFound" Then
MsgBox(0,"Error", "Error: No SDAT entry in update.ini")
Exit 92
EndIf
;MsgBox(0, "SDATName", $SDAT_name)
;$SDAT_url = "http://download.nai.com/products/licensed/superdat/english/intel/" & $SDAT_name
$Full_SDAT_url = $sdat_url & $SDAT_name
; check the size of the file
$size=InetGetSize($Full_SDAT_url)
; download SDATxxxx.exe and save the file to $dest_sdat_path
InetGet($Full_SDAT_url, $dest_sdat_path & "\" & $SDAT_name, 1, 1)
$mypercent= $size/100 ; one percent of the size
While @InetGetActive
$view = (@InetGetBytesRead / $mypercent)
$view = Round($view)
TrayTip("Downloading " & $SDAT_name, "MBytes = " & Round(@InetGetBytesRead/1048576,2) & @CRLF & "Percent: " & $view, 10, 16)
Sleep(250)
Wend
;MsgBox(0, "Download finished! MBytes read: ", Round(@InetGetBytesRead/1048576,2))
[/autoit] [autoit][/autoit] [autoit][/autoit] [autoit];Execute the close environment when the script ends.
Func onAutoItExit()
EndFunc
Func _GetParameters($s_ParamName)
;Create Param Name
Local $s_RealParamName = "-" & $s_ParamName
For $i = 1 To $CmdLine[0] Step 1
If $s_RealParamName = $CmdLine[$i] Then
If $i + 1 <= $CmdLine[0] Then
Return $CmdLine[$i + 1]
EndIf
EndIf
Next
Return ""
EndFunc ;==>_GetParameters
mfg
Axel