SleepyXtreme Posted May 31, 2007 Posted May 31, 2007 (edited) ;===============================================================================;; Function Name: _UpdateProgram;; Description:: Checks to see if your program is up to date. If it isn't, it downloads and runs the installer.;; Parameter(s): $VersionNumber - The version number of your program; $VersionIni - The location of the version.ini file (on the internet, i.e. http://www.yadayadayada.com/version.ini); $InstallFile - The location of the install file (on the internet, i.e. http://www.yadayadayada.com/program.exe); $ProgramName - The name of your program;; Requirement(s): a Version ini file that has says [$ProgramName] on the first line and Version = $VersionNumber on the second line;; ; Author(s): SleepyXtreme;;===============================================================================Func _UpdateProgram($VersionNumber, $VersionINI, $InstallFile,$ProgramName) FileDelete(@TempDir & "/Version.ini") InetGet($VersionINI, @TempDir & "/Version.ini", 1, 1) While @InetGetActive TrayTip($ProgramName, "Checking for Update", 10, 16) Sleep(250) Wend TrayTip("","",0) $version = IniRead(@TempDir & "/Version.ini", $ProgramName, "Version", "") $version2 = $VersionNumber if $version <> $version2 Then MsgBox(0,$ProgramName, "Your software will now be updated to the latest version. ") InetGet($InstallFile, @TempDir & "/"& $ProgramName &"setup.exe", 1, 1) While @InetGetActive TrayTip($ProgramName, "Downloading Update: Bytes = " & @InetGetBytesRead, 10, 16) Sleep(250) Wend TrayTip("","",0) TrayTip($ProgramName,"Downloading Update: Complete",10,16) Sleep(2000) Run(@TempDir & "/"& $ProgramName &"setup.exe") Exit Else MsgBox(0,$ProgramName, "Your software is up to date. ") EndIf EndFuncThis is my first UDF so let me know if i fuxed anything up Edited May 31, 2007 by SleepyXtreme
James Posted May 31, 2007 Posted May 31, 2007 Use {autoit} {/auoit} Replace the {} with []! Very nice. Although many around. Blog - Seriously epic web hosting - Twitter - GitHub - Cachet HQ
SleepyXtreme Posted May 31, 2007 Author Posted May 31, 2007 do you have a link to any others? i couldn't find any . anyways, was my method good?
James Posted May 31, 2007 Posted May 31, 2007 Try searching for Program Updater Blog - Seriously epic web hosting - Twitter - GitHub - Cachet HQ
RazerM Posted May 31, 2007 Posted May 31, 2007 I remember their being a few, good start. I made this one: expandcollapse popup$auto = 1 If $CmdLine[0] > 0 Then If $CmdLine[1] = "DoNotAutoStart" Then $auto = 0 EndIf Local $ping = Ping("www.google.com");Website to ping to check if internet access is available Local $Website = "http://frazergmclean.googlepages.com/Encrypt0r.exe" Local $myini = "http://frazergmclean.googlepages.com/update.ini" $retry = 0 While 1 If $ping = 0 Then $retry = MsgBox(5, "Encrypt0r - Update", "Error! Please connect to the Internet and try again!") EndIf If $retry = 4 Then Local $ping = Ping("www.google.com") EndIf If $retry = 2 Then Exit EndIf If $ping <> 0 Then ExitLoop WEnd If $ping <> 0 Then InetGet($myini, "C:\update.ini", 1) If IniRead("C:\update.ini", "Update", "FileVer", "0.0.0.0") > FileGetVersion("Encrypt0r.exe") Then $msgA = MsgBox(4, "Update", "Encrypt0r " & IniRead("C:\update.ini", "Update", "FileVerDescript", "Not Found") & " is available, Update now?") If $msgA = 6 Then ProcessClose("Encrypt0r.exe") FileMove(@ScriptDir & "\Encrypt0r.exe", @ScriptDir & "\Encrypt0rOld.bak.exe", 1) InetGet($Website, @ScriptDir & "\Encrypt0r.exe", 1, 1) ProgressOn("Downloading Update", "Downloading", "", -1, -1, 16) While @InetGetActive $downloaded = (@InetGetBytesRead / IniRead("C:\Update.ini", "Size", "Bytes", 0) * 100) $downloaded = Int($downloaded) ProgressSet($downloaded) WEnd ProgressOff() $updatecheck = FileExists(@ScriptDir & "\Encrypt0r.exe") $exesize = FileGetSize(@ScriptDir & "\Encrypt0r.exe") If $updatecheck = 1 And $exesize = IniRead("C:\Update.ini", "Size", "Bytes", 0) Then MsgBox(0, "Complete", "Encrypt0r has been updated to: " & IniRead("C:\Update.ini", "Update", "FileVerDescript", "Not Found")) FileDelete(@ScriptDir & "\Encrypt0rOld.bak.exe") If $auto = 1 Then MsgBox(0, "Running Encrypt0r", "Update will now run Encrypt0r", 2) Run(@ScriptDir & "\Encrypt0r.exe") EndIf EndIf If $updatecheck = 0 Or $exesize <> IniRead("C:\Update.ini", "Size", "Bytes", 0) Then FileMove(@ScriptDir & "\Encrypt0rOld.bak.exe", @ScriptDir & "\Encrypt0r.exe", 1) MsgBox(48, "Error!", "The download failed, either the file wasn't downladed or file was corrupt - Updater has restored your previous Encrypt0r file") EndIf EndIf FileDelete("C:\Update.ini") Exit EndIf If IniRead("C:\Update.ini", "Update", "FileVer", "0.0.0.0.") <= FileGetVersion("Encrypt0r.exe") Then MsgBox(0, "Latest", "You currently have the latest version of Encrypt0r") FileDelete("C:\Update.ini") EndIf EndIf My Programs:AInstall - Create a standalone installer for your programUnit Converter - Converts Length, Area, Volume, Weight, Temperature and Pressure to different unitsBinary Clock - Hours, minutes and seconds have 10 columns each to display timeAutoIt Editor - Code Editor with Syntax Highlighting.Laserix Editor & Player - Create, Edit and Play Laserix LevelsLyric Syncer - Create and use Synchronised Lyrics.Connect 4 - 2 Player Connect 4 Game (Local or Online!, Formatted Chat!!)MD5, SHA-1, SHA-256, Tiger and Whirlpool Hash Finder - Dictionary and Brute Force FindCool Text Client - Create Rendered ImageMy UDF's:GUI Enhance - Enhance your GUIs visually.IDEA File Encryption - Encrypt and decrypt files easily! File Rename - Rename files easilyRC4 Text Encryption - Encrypt text using the RC4 AlgorithmPrime Number - Check if a number is primeString Remove - remove lots of strings at onceProgress Bar - made easySound UDF - Play, Pause, Resume, Seek and Stop.
PartyPooper Posted May 31, 2007 Posted May 31, 2007 I have a UDF in my sig that updates a running program that shouldn't be too hard to modify for your needs.
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now