EliTe_ThuT Posted April 15, 2008 Share Posted April 15, 2008 Hi, I have made a program..but I would like to add a code at the beginning for auto-updating... The problem is I don't even know from where to start...I have never done things like that. Someone could point me in the right direction ? Thx Link to comment Share on other sites More sharing options...
monoceres Posted April 15, 2008 Share Posted April 15, 2008 First let the script check if there is a new version, for example download a file named latest_version If the version in the latest_version file is newer than the one installed then download new file (Also specified in latest_version), when done close the script and replace with new version. The simpliest way to do this would be with a batch file. Using this you as a developer can update all client just by uploading a text file and the new version Broken link? PM me and I'll send you the file! Link to comment Share on other sites More sharing options...
EliTe_ThuT Posted April 15, 2008 Author Share Posted April 15, 2008 First let the script check if there is a new version, for example download a file named latest_versionIf the version in the latest_version file is newer than the one installed then download new file (Also specified in latest_version), when done close the script and replace with new version. The simpliest way to do this would be with a batch file.Using this you as a developer can update all client just by uploading a text file and the new version And how do I do that ? The batch file Link to comment Share on other sites More sharing options...
monoceres Posted April 15, 2008 Share Posted April 15, 2008 Here's an example of a batch file that will replace an old file with new: @echo off ping localhost move "newlydownloadedexe.exe" "oldexe.exe" /Y Note that I use ping at the beginning, this is so that your script will have time to close before overwriting begins. Skysnake 1 Broken link? PM me and I'll send you the file! Link to comment Share on other sites More sharing options...
EliTe_ThuT Posted April 15, 2008 Author Share Posted April 15, 2008 (edited) So I would have to have my autoit script check server to see if there is a new version...and then...download the file, then run a .bat file and exit , then the .bat file would run and replace the exe with the new one... and then..what If I want to .bat file open the newlydownloadedexe.exe after ? Edit: I found "START C:\WINDOW\BLABLA" but does this work if I enter a relative path to ? Edited April 15, 2008 by EliTe_ThuT Link to comment Share on other sites More sharing options...
monoceres Posted April 15, 2008 Share Posted April 15, 2008 Edit: I found "START C:\WINDOW\BLABLA" but does this work if I enter a relative path to ?Yes, if you have the bat file in the same dir as your script. Broken link? PM me and I'll send you the file! Link to comment Share on other sites More sharing options...
aGorilla Posted April 15, 2008 Share Posted April 15, 2008 (edited) Not sure where I found this (help file, forum, wiki, one of them)...The comment is mine, believe it. Your script will still be running after it deletes itself, that's your chance to put the new file in it's place.Func _SelfDelete($iDelay = 0); - this is serious! MAKE A BACKUP, OR YOU'LL REGRET IT. Local $sCmdFile FileDelete(@TempDir & "\scratch.bat") $sCmdFile = 'ping -n ' & $iDelay & '127.0.0.1 > nul' & @CRLF _ & ':loop' & @CRLF _ & 'del "' & @ScriptFullPath & '"' & @CRLF _ & 'if exist "' & @ScriptFullPath & '" goto loop' & @CRLF _ & 'del ' & @TempDir & '\scratch.bat' FileWrite(@TempDir & "\scratch.bat", $sCmdFile) Run(@TempDir & "\scratch.bat", @TempDir, @SW_HIDE) EndFuncEdit: found the original post: here.Q12 - about half way down the page. Edited April 15, 2008 by aGorilla Skysnake 1 Search AutoItScript.com via Google Link to comment Share on other sites More sharing options...
EliTe_ThuT Posted April 15, 2008 Author Share Posted April 15, 2008 Not sure where I found this (help file, forum, wiki, one of them)... The comment is mine, believe it. Your script will still be running after it deletes itself, that's your chance to put the new file in it's place. Func _SelfDelete($iDelay = 0); - this is serious! MAKE A BACKUP, OR YOU'LL REGRET IT. Local $sCmdFile FileDelete(@TempDir & "\scratch.bat") $sCmdFile = 'ping -n ' & $iDelay & '127.0.0.1 > nul' & @CRLF _ & ':loop' & @CRLF _ & 'del "' & @ScriptFullPath & '"' & @CRLF _ & 'if exist "' & @ScriptFullPath & '" goto loop' & @CRLF _ & 'del ' & @TempDir & '\scratch.bat' FileWrite(@TempDir & "\scratch.bat", $sCmdFile) Run(@TempDir & "\scratch.bat", @TempDir, @SW_HIDE) EndFunc Edit: found the original post: here. Q12 - about half way down the page. Wow so in fact, if I use this...I do not need a .bat file... Link to comment Share on other sites More sharing options...
aGorilla Posted April 15, 2008 Share Posted April 15, 2008 Well, you won't 'need' one, but you'll use one. That creates the batch that deletes your script, then deletes itself. It's quite cool (and just a bit dangerous). Search AutoItScript.com via Google Link to comment Share on other sites More sharing options...
EliTe_ThuT Posted April 15, 2008 Author Share Posted April 15, 2008 Well, you won't 'need' one, but you'll use one. That creates the batch that deletes your script, then deletes itself. It's quite cool (and just a bit dangerous).Oh yeah I see it (didn't saw the filewrite parth)Anyway that's cool Link to comment Share on other sites More sharing options...
aGorilla Posted April 16, 2008 Share Posted April 16, 2008 (edited) Ok, I took a shot at this (I needed one anyway), and here's a rough example.Version 1 - this is what you run.http://www.theholyfind.com/au3/upgrade/upgrade.au3Version 2 - if it works, this is what you'll end up with.http://www.theholyfind.com/au3/upgrade/upgrade-2.00.au3This is how version 1 finds out there's a new (ie: different) version.http://www.theholyfind.com/au3/upgrade/latest.htmlAll comments, criticisms, suggestions, etc. are welcome.p.s.: I'd love to see a progress bar for it, if anyone has the time.p.p.s.: It seems to work without the self-deletion code, somehow, I thought I would need that. Edited April 16, 2008 by aGorilla Search AutoItScript.com via Google Link to comment Share on other sites More sharing options...
Swift Posted April 16, 2008 Share Posted April 16, 2008 I have made a updater, go a forum search for: Global Updater Link to comment Share on other sites More sharing options...
aGorilla Posted April 16, 2008 Share Posted April 16, 2008 Sure, now you tell me! If only you were a little... Swifter Search AutoItScript.com via Google Link to comment Share on other sites More sharing options...
Swift Posted April 16, 2008 Share Posted April 16, 2008 I was busy Source is provided But Congrats! Link to comment Share on other sites More sharing options...
aGorilla Posted April 16, 2008 Share Posted April 16, 2008 No worries, and thanks. I had fun with it, and it'll probably suit me for what I'm working on now.Scanning through your code now, maybe I'll learn something Search AutoItScript.com via Google Link to comment Share on other sites More sharing options...
EliTe_ThuT Posted April 16, 2008 Author Share Posted April 16, 2008 No worries, and thanks. I had fun with it, and it'll probably suit me for what I'm working on now.Scanning through your code now, maybe I'll learn something Good thx everyone...I'll probably just look at both of your code and make my own updater with it. Link to comment Share on other sites More sharing options...
aGorilla Posted April 16, 2008 Share Posted April 16, 2008 One final thought... Any 'Auto Upgrade' program should include some form of 'Post Upgrade' function. The first program to use it will probably just contain 'Return true', but it gives you a placeholder to call in the future. You can use it to add any cleanup code (eg: deleting old files that are no longer used, etc. -- which Swift has in _Cleanup()), or for it to continue with the upgrade (downloading other files, etc.). Search AutoItScript.com via Google Link to comment Share on other sites More sharing options...
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