Jump to content

updater which allows ability to update updater itself?


Recommended Posts

i have a script that detects if theres a newer version (checks on a lan share)

(taken from script that gets updated)

Func Auto_UpdateCheck()
    If Not FileExists("\\serverpath") Then
        MsgBox(262144, "Check for Updates", "\\serverpath is not accessible.")
        Return
    EndIf

    $search = FileFindFirstFile("\\serverpath\scriptname*.exe")

    If $search = -1 Then
        MsgBox(262144, "Check for Updates", "Script cannot be found in \\serverpath.")
        Return
    EndIf

    While 1
        $file = FileFindNextFile($search)
        If @error Then ExitLoop
        $recent_ver = StringTrimRight($file, 4)
    WEnd

    If $ver < $recent_ver Then
        Get_Update()
    EndIf
EndFunc

Func Get_Update()

    If FileExists(@ScriptDir & "\_updater.exe") Then
        FileMove(@ScriptDir & "\_updater.exe", @ScriptDir & "\updater.exe", 1)
    EndIf

    If FileExists(@ScriptDir & "\updater.exe") Then
        Run(@ScriptDir & "\updater.exe")
        Exit
    Else
        MsgBox(262144, "Script", "UPDATER.EXE was not found in " & @ScriptDir & @CRLF & _
                "Please manually extract/replace your folder with server copy.")
        _IECreate("file://serverpath", 0, 1, 0)
    EndIf

EndFunc   ;==>Get_Update

the file on the server is a self extracting executable that has the new version of the script along with updater.exe (current updater) and _updater.exe (new updater.exe)

_updater.exe gets renamed to updater.exe (so far the only way i can think of on how to update the updater)

problem is.. new updater doesn’t run till the next update. because updater is in use, when its trying to replace it!

can anyone think of a more clever way to allow for not only the updating but also the replacement of the updater itself?

Edited by gcue
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...