AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Check For Updates Script

 
Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions
View previous topic :: View next topic  
Author Message
Travley



Joined: 13 May 2007
Posts: 47

PostPosted: Tue Jun 19, 2007 5:52 am    Post subject: Check For Updates Script Reply with quote

Wrote a version for someone in the help section and someone asked that I post in this section from now on, with things like this. So here goes my first 'script' post. Enjoy.

Code:
FileName = yourapp.zip
CurrentVersionNum := 1.0
NewestVersionURL = YourApp-Updated.zip
AppName = Your Application
SiteUrl = http://www.yoursite.com/apps/
NewVersionCheckFile = thisapp-version.txt

UpdateCheck:
    {
        SplashTextOn, 340, 24, Checking For Updates..., Please wait while %AppName% checks for updates.
        FileDelete, %TEMP%\%NewVersionCheckFile%
        UrlDownloadToFile, %SiteUrl%%NewVersionCheckFile%, %TEMP%\%NewVersionCheckFile%
        FileRead, NewestVersionNum, %TEMP%\%NewVersionCheckFile%
        SplashTextOff
        If ErrorLevel = 1
    {
        MsgBox, 16, Error,  There was a problem checking for updates.`n`nPlease try again, or visit %SiteUrl% to check and download manually.
        Return
    }
        Else
    {

        If (CurrentVersionNum >= NewestVersionNum)
    {
        MsgBox, 48, Currently Up To Date!, You are using the newest version of %AppName%!
        FileDelete, %TEMP%\%NewVersionCheckFile%
        Return
    }
        Else
    {
        MsgBox, 4, Would you like to update?, You are currently using an out of date verison of %AppName%.`n`nWould you like to update to the newest version?
        IfMsgBox No
    {
    return
    }
        IfMsgBox Yes
    {
        FileSelectFolder, FileSaveDir, , 1, Please select your %AppName% directory. Or the directory you wish to save the new %FileName% to.,
        SplashTextOn, 340, 24, Downloading Updates..., Please wait while %AppName% Updates.       
        UrlDownloadToFile, %NewestVersionURL%, %FileSaveDir%\%FileName%
        goto Downloaded
    }
       

    Downloaded:   
        Loop,
    {
        If A_Index = 100 ; Change this to whatever fits your connection.
       {
        Goto DownloadError
       }
        IfExist, %FileSaveDir%\%FileName%
       {
        Goto DownloadDone
       }
    }


    DownloadDone:
    {
        SplashTextOff
        MsgBox, 48, Success!, %filename% has been successfully downloaded to %FileSaveDir%.`n`nYou are now currently up to date. Enjoy!
        FileDelete, %TEMP%\%NewVersionCheckFile%
        Return
    }
       
    DownloadError:
    {
        SplashTextOff
        MsgBox, 16, Error, There seemed to be a problem with the download.`n`nPlease try again, or visit %SiteUrl% to download directly.
        FileDelete, %TEMP%\%NewVersionCheckFile%
        Return
    }
  }
 }
}
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group