Jump to content

Recommended Posts

Good day all,

 

I am trying to find out what approach you guys take to update your app say from a file or web server to make sure the latest version is always being used. I looked through the help file and UDF's but I am not seeing anything for this, perhaps I am looking for the wrong terms.

Link to post
Share on other sites

Well, I have a location on one of our servers in the LAN and on every start the local version is compared to the version on the server.

General way of updating the compiled exe is:

  1. rename current exe to _old.exe (yes, the exe file is able to rename itself)
  2. copy the new exe to the local computer
  3. run the new exe
Func Updateholen()
    Local $updatepfad = "\\server\myprogram\" ; Folder to get the Updates
    Local $updatequelle = $updatepfad & "myfile.exe" ; FileName to check for
    Local $tmp1 = ""
    Local $tmp2 = ""

    If FileExists(@ScriptDir & "\myfile_old.exe") Then FileDelete(@ScriptDir & "\myfile_old.exe") ; delete possibly existing old version
    If Not @Compiled Then Return ; only try to update if started as a compiled exe

    If @AutoItX64 = 1 Then $updatequelle = $updatepfad & "myfile_x64.exe"

    If Not Ping("server", 50) Then Return ; if server is not online, update can not be retrieved

    If FileExists($updatequelle) Then
        $tmp1 = FileGetTime($updatequelle, 0, 1)
        $tmp2 = FileGetTime(@AutoItExe, 0, 1)
        If $tmp1 > $tmp2 Then

            ; rename the currently running exe file
            $tmp1 = FileMove(@AutoItExe, @ScriptDir & "\userinfo_alt.exe")
            If $tmp1 <> 1 Then
                MsgBox(16, "Problem", "Could not rename the running exe")
                Exit
            EndIf

            ; copy the new exe file to our PC
            $tmp1 = FileCopy($updatequelle, @AutoItExe)
            If $tmp1 <> 1 Then
                MsgBox(16, "Problem", "Could not copy the update")
                Exit
            EndIf

            ; notify user about the update and display version history
            If FileExists($updatepfad & "history.htm") Then ShellExecute($updatepfad & "history.htm")
            Run(@AutoItExe)
            Exit
        EndIf
    EndIf
EndFunc   ;==>Updateholen

 

Edited by Marc
typo

Any of my own codes posted on the forum are free for use by others without any restriction of any kind. (WTFPL)

Link to post
Share on other sites

A good place to start is this thread:

 

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2021-06-05 - Version 1.5.4.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (NEW 2021-06-14 - Version 1.6.5.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (NEW 2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2019-12-03 - Version 1.5.1.0) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

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
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...