Travley
Joined: 13 May 2007 Posts: 47
|
Posted: Tue Jun 19, 2007 5:52 am Post subject: Check For Updates Script |
|
|
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
}
}
}
} |
|
|