Jump to content
Sign in to follow this  

Update existing exe from web downloaded file

Recommended Posts


i made this script for my self to download file from my website/extract it and replace original EXE with newly extracted.

Its an updater, not a part of code.

This has to be compiled separately.

#include <ProgressConstants.au3>

$FileToUpdate = "my program.exe"
$FileToDownload = "compressed.rar"
$FileDownloadURL = "http://www.mywebsite.com"
$FileToReplace = (@ScriptDir & "\" & $FileToUpdate)
$Decompressor = "UnRAR.exe"
$DecompressCommand = ($Decompressor & " x -o+ " & $FileToDownload)

Func Updater()
    FileRecycle (@ScriptDir & "\" & $FileToDownload)
    ProcessWaitClose ($FileToUpdate) ;Wait for process to close before file will be available for replacement
    $FileSize = InetGetSize ($FileDownloadURL & $FileToDownload,1)
    $FileDownloading = InetGet ($FileDownloadURL & $FileToDownload, @ScriptDir & "\" & $FileToDownload,1,1) ;1 for Force redownload, 1 for Do not wait till downloaded and go next
    ProgressOn ("Download progress", "Downloading file ", "0 %") ;start progress bar windows
        For $i = 1 to $FileSize step 1
        $FileDownloadingInfo = InetGetInfo ($FileDownloading)
        $FilePercentDownloaded = Round($FileDownloadingInfo[0]*100/$FileSize, 2)
        ProgressSet($FilePercentDownloaded, $FilePercentDownloaded & " %")
        ;GUICtrlSetData ($progress,$percentDownloaded)
            If InetGetInfo($FileDownloading,2) Then
        ProgressSet(100 , "100%", "Download completed.")

        RunWait ($DecompressCommand)
        FileMove (@ScriptDir & "\" & $FileToUpdate,@ScriptDir & "\" & $FileToUpdate,1)
        FileRecycle (@ScriptDir & "\" & $FileToDownload) ;erase downloaded file
        MsgBox(0,'Information','Update Complete !')

Share this post

Link to post
Share on other sites

It does not Work For me... can you update please?

Share this post

Link to post
Share on other sites


the first post was made nearly 2 years ago and, as you should be able to see, madasraka has not posted in these forums for about a year. Since there are a lot of settings that you have to make to suit what you want to do it would have been sensible to at least have given detailed information about exactly what failed, error messages and so on. In any case, since the script is very simple and short, you should be able to either sort out the problem yourself or by asking for help (with plenty of relevant information) in general help.

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

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