sandman Posted August 12, 2007 Share Posted August 12, 2007 Hi everybody,I've written a fairly simple but useful program updater that you can make your program run every time it is executed. Feel free to use this as a base for a updater GUI, or anything of the sort.Before I show the code, the logic of this.Meet Bob. Bob just downloaded your program, which is currently at version 0.9. Once he runs the installer, there will be at least two files extracted into the program's directory: The main program EXE, and a file called 'settings.ini'. Inside 'settings.ini' is the section Version, and inside that is the key 'version'. The value of this key is... you guessed it. '0.9'.Bob is enjoying your program a lot. A few weeks later, you release version 1.0 of the program. The very next time Bob runs his program after you release that, your program will download a file from your site called 'update.exe', like every other time your program starts up. Your program waits for update.exe to finish before continuing. So update.exe is running, and it notices that 'settings.ini' has a version of 0.9 still. It fixes this! This is the part that you need to customize, depending on what updates you need. It will close the running program, and replace all necessary files.Otherwise, it exits and lets the program run on!Remember, you need to compile these for it to work. Compile update.au3 as update.exe, and myprogram.au3 to myprogram.exe. Of course you can rename these and change the actions if you would like to.myprogram.au3:; myprogram.exe ; THIS MUST BE COMPILED TO WORK!! Otherwise it cannot find myprogram.exe ; Load the updater.... If INIRead("settings.ini", "Version", "version", "nocurrentversion") = "nocurrentversion" Then INIWrite("settings.ini", "Version", "version", "1.0") ; An example. If there's no INI file yet, put the version in. InetGet("http://www.example.com/Your Update File.exe", "update.exe", 1) ; Get the update file... force a reload from the site, no caching! RunWait("update.exe") ; Run the updater ; My Program... blah blah blah.Enjoy! [center]"Yes, [our app] runs on Windows as well as Linux, but if you had a Picasso painting, would you put it in the bathroom?" -BitchX.com (IRC client)"I would change the world, but they won't give me the source code." -Unknownsite . blog . portfolio . claimidcode.is.poetry();[/center] Link to comment Share on other sites More sharing options...
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
Already have an account? Sign in here.Sign In Now