Sign in to follow this  
Followers 0
marko001

Program Update from Internet

5 posts in this topic

Hi all,

I was looking for an UDF to help me check and DL/Install the .exe if it finds a new version from the website.

I see there were 2 UDF here (_INetUpdater() and InetFileUpdate) but I can't get them anymore here.

Is there a new UDF around?

This part is good:

#include-once
;===============================================================================
;
; Function Name:    _INetUpdateCheck()
; Description:      A simple UDF that can be used for updating programs via the internet
;     removed       Includes a progress bar and an option to automatically update the running script.
; Version:          1.0.0.1
; Parameter(s):     $s_inu_CurrentVersion - current program version number
;                   $s_inu_WebSite - website containing version file and executable
;                   $h_inu_IniFileName - Ini file on website containing version number
;     removed       $h_inu_RemoteFileName - executable filename to be downloaded
;     removed       $h_inu_LocalFileName - executable filename to be saved. Default (-1) - same as Remote Filename
;     removed       $h_inu_LocalBatchFile - batch Updater filename. Default (-1) - "INetUpdater.bat"
;     removed       $i_inu_AutoInstall - auto install after downloading 0=no, 1=yes.  Default (0) - manually install update
; Requirement(s):   AutoIt Beta > 3.1
;                   Version control file located on webserver
; Return Value(s):  On Success - Downloads and installs, if chosen, the update
;                   Modification does not include download or install but asks user if they would like to.
;                   On Failure - sets @ERROR = 1 for function parameter errors
;                              - sets @ERROR = 2 if internet/version file not be available
;                              - sets @ERROR = 3 if updating batch file cannot be created
; Forum(s):         http://www.autoitscript.com/forum/index.php?showtopic=20082
;            http://www.autoitscript.com/forum/index.php?showtopic=47429
; Author(s):        Original code - PartyPooper
;                   Modifications - Mast3rpyr0
;
;===============================================================================
Func _INetUpdateCheck($s_inu_CurrentVersion, $s_inu_WebSite, $h_inu_IniFileName)
    If $s_inu_CurrentVersion = "" Then SetError(1) ; user didn't set current program version.  Set @error = 1
    If $s_inu_WebSite = "" Then SetError(1) ; user didn't set website address.  Set @error = 1
    If $h_inu_IniFileName = "" Then SetError(1) ; user didn't set Remote INI filename.  Set @error = 1
    If @error Then Return ; return to calling function with @error = 1
    Local $h_inu_GetVersFile = InetGet($s_inu_WebSite & "\" & $h_inu_IniFileName, @TempDir & "\" & $h_inu_IniFileName) ; download version file from web to temp dir
    If $h_inu_GetVersFile = 0 Then  ; version file or internet not available
        MsgBox(262160, "ERROR", "Update check failed.  Website/internet/version file not available at this time.")
        SetError(2) ; set @error to 2
        Return ; return to calling function with @error = 2
    EndIf
    Local $s_inu_LatestVersion = IniRead(@TempDir & "\" & $h_inu_IniFileName, "Program Version", "Vers", 0) ; grab latest version number
    FileDelete(@TempDir & "\" & $h_inu_IniFileName) ; delete downloaded version file - no longer needed
    If $s_inu_LatestVersion <> $s_inu_CurrentVersion Then ; check latest version number against current version number and update if needed
        $doUpdate = MsgBox(4, "Update Available", "There is a new Version of Game Launcher available. Would you like to download?")
        If $doUpdate == 6 Then
            Update() ; Function that will run _INetUpdater. Add this to source:
            #cs
            Func Update()
            SplashTextOn("Program Name", "Checking for updates....", 250, 30, -1, -1, 0)
            _INetUpdater("Current version", "Website", "new version ini", "target file")
            SplashOff()
            EndFunc ;==>Update
            #ce
        EndIf
    If $s_inu_CurrentVersion = $s_inu_LatestVersion Then MsgBox(262640, "Game Launcher", "Program is up to date.")
    EndIf
    SetError(0)
    Return
EndFunc ;==>_INetUpdateCheck

but it calls _iNetUpdater I don't have

Thanks,

M.

Share this post


Link to post
Share on other sites



Hi,

first wirte down all the steps you need, then writing the funtion on your own should or with help of the forum it shouldn't be a problem.

1) Get the version? Where to find it? txt on a webserver?

2) Read the info

3) Read the info from the exe itself

4) compare

5) if there is a new one, download

6) Suicide function to delete the old script

7) done :-)

Mega


Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Share this post


Link to post
Share on other sites

Hey,

An other way to do it is :

1) DL the version on the website.

2) Compare with the actually (take a look to : _VersionCompare() )

3) Decide in consequence.

Jérôme

Share this post


Link to post
Share on other sites

@ xeno:

You right, I followed your hints and got it step by step using standard functions.

Share this post


Link to post
Share on other sites

@ xeno:

You right, I followed your hints and got it step by step using standard functions.

Fine! It is always good having and following a concept :huh2:


Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

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