Sign in to follow this  
Followers 0
anystupidassname

edumacate me please?

5 posts in this topic

#1 ·  Posted (edited)

I've been using this for a while but I'd say it fails about 10% of the time. Not a big deal but I'm a noob and would like input. I know the experienced coders here are going to break down and cry but any suggestions are welcome. Even if it means scrapping all my "code".

This script is run as frequently as hourly or infrequently as daily to update the virus definitions for Symantec Antivirus.

I think my two main problems (aside from being a noob) are the download failing and how I prevent duplicate instances from running (couldn't get singelton to work). Please advise if more commenting in the code is necessary. Thanks.

P.S. this only works on SAV 8+ client and Win XP.

Opt("RunErrorsFatal", 0)
Opt("TrayAutoPause", 0)
Opt("TrayMenuMode", 1)
TraySetState (@SW_TRAYFLASH)

If UBound(ProcessList(@ScriptName)) > 2 Then; check for dup process and kill all processes if found - eventually I'd like to get it to kill all processes and then relaunch immediately...
    While ProcessExists("updater.exe")
        ProcessClose("updater.exe")
    WEnd
    Exit
EndIf

ProcessSetPriority ("updater.exe", 1); adjust for process name!

$defchk1 = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Symantec\SharedDefs","DEFWATCH_10"); defdate in use
$defchk1 = StringRight($defchk1, 12); formatting
$defchk0 = StringLeft($defchk1, 8); formatting
$rrlr = RegRead("HKLM\SOFTWARE\INTEL\LANDesk\VirusProtect6\CurrentVersion\","RRCLTUP_LAST_RUN"); leave a tell
$today = (@YEAR & @MON & @MDAY)
$todayh = ($today & @HOUR)

If ($today - $defchk0) > "1" Then
    MsgBox(48,"Warning","Definitions are more than a day old!" & @CRLF & "Continuing in 15 seconds...", 15)
EndIf; squawk if defs were old

If NOT IsAdmin() Then
    MsgBox(48,"","Administrator rights required! Aborted...")
    Exit
EndIf; don't run if not administrator

$sv = StringLeft(@SystemDir, 2)
$ds = DriveSpaceFree($sv); make sure not low on disk space

If $ds < "500" Then
    MsgBox(48,"Warning!","Your system volume '" & $sv & "' has less than 500MB of free space!" & @CRLF & "Please make some room! Continuing in 15 seconds...", 15)
EndIf; warn and continue if low on disk space

$ct = Regread("HKLM\SOFTWARE\INTEL\LANDesk\VirusProtect6\CurrentVersion\","ClientType"); verify it is a SAV client - won't work on server (purposely)
$d = "ftp://ftp.symantec.com/AVDEFS/symantec_antivirus_corp/rapidrelease/navup.exe"; were to get defs
RegWrite("HKLM\SOFTWARE\INTEL\LANDesk\VirusProtect6\CurrentVersion\","RRCLTUP_LAST_RUN"  ,"REG_SZ", $todayh); check against tell

If NOT $ct < "0" OR $ct > "2" Then
    MsgBox(48, "Abort", "Update Aborted... No Symantec Antivirus Client found.")
    Exit
EndIf

$size = InetGetSize($d)
TrayTip("Automatic SAV Definition Updater", "Starting definition download..", 1, 1)
InetGet($d, @Tempdir & "\rapidreleasevirusdefinition.exe", 1, 1)
While @InetGetActive = 1
;no decimal percentage dl;TrayTip("Automatic SAV Definition Updater", "Downloading definitions... " & Int(@InetGetBytesRead / $size * 100) & "%", 0, 1)
    TrayTip("Automatic SAV Definition Updater", "Downloading definitions... " & (Int(@InetGetBytesRead / $size * 10000)/100) & "%", 0, 1)
    Sleep(100)
WEnd; download with system traytip progress in percent
If FileGetSize(@Tempdir & "\rapidreleasevirusdefinition.exe") <> $size Then
    MsgBox(48,"Error","Download failed!")
    Run(@ComSpec & " /c " & 'EVENTCREATE /ID 1 /L Application /T ERROR /SO "SAV Updater" /D "Virus Definition download failed"', "", @SW_HIDE)
    Exit
EndIf; check if download successful (this is what seems to fail 10%-15% of the time...)
TrayTip("Automatic SAV Definition Updater", "Download Complete!", 10, 1)

$ic = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Symantec\InstalledApps","AVENGEDEFS"); all the rest of this stuff is just applying the defs and make eventlog entries to reflect success or failure (works 100% no problems)

Run(@ComSpec & " /c " & 'net stop "Symantec Antivirus Definition Watcher', "", @SW_HIDE)

$chk = DirRemove($ic & "\incoming",1)
If $chk <> "1" Then
    Run(@ComSpec & " /c " & 'EVENTCREATE /ID 1 /L Application /T ERROR /SO "SAV Updater" /D "Virus Definition update failed"', "", @SW_HIDE)
    MsgBox(48,"Error","Virus definition update failed!")
    Exit
EndIf
DirCreate($ic & "\incoming")
FileInstall ( "H:\My Documents\AutoIt Projects\AIU\20051019\unzip.exe", $ic & "\incoming\unzip.exe", 1)
FileMove(@Tempdir & "\rapidreleasevirusdefinition.exe", $ic & "\incoming", 1)
Runwait($ic & "\incoming\rapidreleasevirusdefinition.exe", $ic & "\incoming\", @SW_HIDE)
Sleep(1000)
FileMove($ic & "\incoming\*.vdb", $ic & "\incoming\1.zip", 1)
Sleep(1000)
FileDelete($ic & "\incoming\rapidreleasevirusdefinition.exe")
Sleep(1000)
RunWait($ic & "\incoming\unzip.exe 1.zip",$ic & "\incoming\", @SW_HIDE)
Sleep(1000)
FileDelete($ic & "\incoming\1.zip")
Sleep(1000)
DirRemove($ic & "\incoming\WILD",1)
Sleep(1000)
FileDelete($ic & "\incoming\unzip.exe")

TraySetState (@SW_TRAYNOFLASH)
TrayTip("Automatic SAV Definition Updater", "Applying update...", 10, 1)
RunWait(@ComSpec & " /c " & 'net start "Symantec Antivirus Definition Watcher', "", @SW_HIDE)
Sleep(10000)
If NOT ProcessExists("Defwatch.exe") Then
    Run(@ComSpec & " /c " & 'EVENTCREATE /ID 1 /L Application /T ERROR /SO "SAV Updater" /D "One of the SAV services did not restart!"', "", @SW_HIDE)
    MsgBox(48,"Error","One of the SAV services did not restart!")
    Exit
EndIf
If NOT ProcessExists("Rtvscan.exe") Then
    Run(@ComSpec & " /c " & 'EVENTCREATE /ID 1 /L Application /T ERROR /SO "SAV Updater" /D "One of the SAV services did not restart!"', "", @SW_HIDE)
    MsgBox(48,"Error","One of the SAV services did not restart!")
    Exit
EndIf
Sleep(10000)
$defchk2 = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Symantec\SharedDefs","DEFWATCH_10")
$defchk2 = StringRight($defchk2, 12)

If NOT $defchk2 > $defchk1 Then
    If NOT $rrlr < ($todayh + 2) Then
        Run(@ComSpec & " /c " & 'EVENTCREATE /ID 1 /L Application /T ERROR /SO "SAV Updater" /D "Virus Definition update failed!"', "", @SW_HIDE)
        MsgBox(48,"Error","Virus definition update failed!")
    EndIf
    Exit
EndIf

TrayTip("Automatic SAV Definition Updater", "Update Complete!", 10, 1)
Sleep(10000)

Run(@ComSpec & " /c " & 'EVENTCREATE /ID 1 /L Application /T INFORMATION /SO "SAV Updater" /D "Virus Definitions updated successfully to ' & $defchk2 & '."', "", @SW_HIDE)
Exit
Edited by anystupidassname

This signature is computer generated, nothing can go wron#nothing can go wron#nothing can go wron#nothing can go wron#nothing can go wron#nothing can go wron#nothing can go wron#nothing can go wron#nothing can go wron#nothing can go wron#nothing can go wron#.......

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

I switched to using wget instead of the builtin download functions of AutoIt and it is close to 100% effective now. The only disadvantage is the tool is now 500k instead of 210k

Edited by anystupidassname

This signature is computer generated, nothing can go wron#nothing can go wron#nothing can go wron#nothing can go wron#nothing can go wron#nothing can go wron#nothing can go wron#nothing can go wron#nothing can go wron#nothing can go wron#nothing can go wron#.......

Share this post


Link to post
Share on other sites

Wow, two identical issues tonight. One easy answer.

Try adding this routine at the beginning of your script to prevent multiple instances from running.

$sVersion = "Updater"

If WinExists($sVersion) Then Exit

AutoItWinSetTitle($sVersion)

Share this post


Link to post
Share on other sites

Sleep(100)
WEnd; download with system traytip progress in percent
If FileGetSize(@Tempdir & "\rapidreleasevirusdefinition.exe") <> $size Then
    MsgBox(48,"Error","Download failed!")
Have you tried a sleep between WEnd and If FileGetSize? Perhaps the download is not really done before you check the size??? Just a thought....

...by the way, it's pronounced: "JIF"... Bob Berry --- inventor of the GIF format

Share this post


Link to post
Share on other sites

Wow, two identical issues tonight. One easy answer.

Try adding this routine at the beginning of your script to prevent multiple instances from running.

$sVersion = "Updater"

If WinExists($sVersion) Then Exit

AutoItWinSetTitle($sVersion)

Thanks, that method is a bit "cleaner". Wish I could figure out _singleton B)

Have you tried a sleep between WEnd and If FileGetSize? Perhaps the download is not really done before you check the size??? Just a thought....

Thanks for the reply. I thought of that and tried adding some sleep(####) and coffee and some swear words... The problem is the download is failing. I think the FTP server OR their connection OR my connection sucks? Anyway, wget is working like a champ :o , plus it can retry if necessary, plus it seems to be faster, plus it has passive / active capabilities etc...


This signature is computer generated, nothing can go wron#nothing can go wron#nothing can go wron#nothing can go wron#nothing can go wron#nothing can go wron#nothing can go wron#nothing can go wron#nothing can go wron#nothing can go wron#nothing can go wron#.......

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0