Simplify CureIt update process with AutoIt

AutoIt

I had previously covered (and numerously mentioned) DrWeb CureIt which is one of the core anti-malware tools for me. Since it is free promotional tool from company that is in the business of selling software there are some limitations in place.

One of them is having to download CureIt to update it. So I made script in AutoIt to help with that.

CureIt update scheme

App is provided as single executable (which is actually self-extracting and self-running RAR archive) by developer. Version is not encoded in file name so link is always the same.

If app is over few days old on run it will present dialog offering to go and download latest executable. Downloading that file all the time gets boring very fast.

Creating wrapper

Messing with CureIt package is no use – it just not designed to have update capabilities. So I decided to create wrapper – separate small script that will take care of checking how outdated CureIt is and re-downloading it.

Step by step

#include "Date.au3"
$path = @ScriptDir
$cureit = $path & "\cureit.exe"
$old = $path & "\cureit_old.exe"
$update = 24
$url="ftp://ftp.drweb.com/pub/drweb/cureit/cureit.exe"

Initial setup:

  • going to use some date calculations;
  • working in same directory where script is placed;
  • two paths for CureIt executable and backup of it (just in case);
  • update every 24 hours;
  • URL to download CureIt from.
If FileExists($cureit) Then
    $f = FileGetTime($cureit)
    $f = $f[0]&"/"&$f[1]&"/"&$f[2]&' '&$f[3]&':'&$f[4]&':'&$f[5]
    $since = _DateDiff("h", $f, _NowCalc())
    TrayTip("CureIt", "Last updated " & $since & " hours ago", 10)
EndIf

If CureIt executable is present then calculate how long ago it was last modified.

If Not FileExists($cureit) Or $since >= $update Then
    FileCopy($cureit,$old,1)
    TrayTip("CureIt", "Attempting update", 10)
    If InetGet($url, $cureit, 1) Then
        TrayTip("CureIt", "Update succesful", 10)
    Else
        FileCopy($old,$cureit,1)
        TrayTip("CureIt", "Update failed", 10)
    EndIf
EndIf

If CureIt not present or update is needed then back it up and attempt to download latest version.

If FileExists($cureit) Then ShellExecute($cureit)
Sleep(3*1000)
Exit

Launch CureIt and pause for a while so tray message with information doesn’t disappear too fast.

No more rummaging through bookmarks to find that FTP link and download file. :) As always I only show core function and there is lot of potential here – CureIt can be unpacked and after that it supports quite a few command line arguments that can be used to make it do more stuff fully automated.

Script https://www.rarst.net/script/cureitupdater.au3

Related Posts

2 Comments

Comments are closed.