Sign in to follow this  
Followers 0
Splash

Automatic Update UDF

2 posts in this topic

#1 ·  Posted (edited)

#cs
    Author: Igor "Splash" Cemim
    Profile: http://www.autoitscript.com/forum/index.php?showuser=46021
    Email: igor dot cemim at yahoo dot com dot br

    Thanks to _SelfDelete author (???). :)
#ce

;$scriptVersion = Your current script version.
;$iniUrl = URL to your update configuration file.
;$fileName = Local name to file that will be downloaded.
;$fileName = Local name to configuration file that will be downloaded.
Func CheckUpdate($scriptVersion, $iniUrl, $fileName = "update.exe", $iniName = "update.ini")
    InetGet($iniUrl, $iniName, 1)
    $lastestVersion = IniRead($iniName, "Update", "lastestVersion", 0)
    $updateUrl = IniRead($iniName, "Update", "updateUrl", 0)
    If ($lastestVersion > $scriptVersion) Then
        InetGet($updateUrl, $fileName, 1, 0)
        FileDelete(@ScriptDir & "\" & $iniName)
        _DoUpdate(@ScriptDir & "\" & $fileName)
    EndIf
EndFunc   ;==>CheckUpdate

;$newFile = Updated file.
;$iDelay = Delay between commands.
Func _DoUpdate($newFile, $iDelay = 4)
    Local $sCmdFile
    FileDelete(@TempDir & "\doIt.bat")
    $sCmdFile = 'ping -n ' & $iDelay & ' 127.0.0.1 > nul' & @CRLF _
             & ':loop' & @CRLF _
             & 'del "' & @ScriptFullPath & '" > nul' & @CRLF _
             & 'if exist "' & @ScriptFullPath & '" goto loop' & @CRLF _
             & 'ping -n ' & $iDelay & ' 127.0.0.1 > nul' & @CRLF _
             & 'rename "' & $newFile & '" "' & @ScriptName & '" > nul' & @CRLF _
             & 'ping -n ' & $iDelay & ' 127.0.0.1 > nul' & @CRLF _
             & '"' & @ScriptFullPath & '" > nul ' & @CRLF _
             & 'del "' & @TempDir & '\doIt.bat" > nul'
    FileWrite(@TempDir & "\doIt.bat", $sCmdFile)
    Run(@TempDir & "\doIt.bat", @TempDir, @SW_HIDE)
    Exit
EndFunc   ;==>_DoUpdate

Sample configuration file:

[Update]
lastestVersion=2
UpdateUrl=http://www.mysite.com/update/newfile.exe

If have any question please ask. ;)

Sorry any english grammar errors.

Igor Ferreira Cemim

Edited by Splash

Automatic Update UDF - IP Address UDF - WinPcap AutoIt _FindDevice()[font="Verdana"][size="2"]AutoIt Spanish/Brasil/World community!!![/size][/font]Use you wanna a dot.tk domain please use my link:

Share this post


Link to post
Share on other sites



It is simply too simple. ;) One doesn't need an UDF for that.


[Not using this account any more. Using "iShafayet" instead]

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