Jump to content

Auto Upgrade my program


Recommended Posts

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

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 :D

Broken link? PM me and I'll send you the file!

Link to comment
Share on other sites

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 :D

And how do I do that ? The batch file

Link to comment
Share on other sites

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.

Broken link? PM me and I'll send you the file!

Link to comment
Share on other sites

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 by EliTe_ThuT
Link to comment
Share on other sites

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.

Edited by aGorilla
Link to comment
Share on other sites

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

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.au3

Version 2 - if it works, this is what you'll end up with.

http://www.theholyfind.com/au3/upgrade/upgrade-2.00.au3

This is how version 1 finds out there's a new (ie: different) version.

http://www.theholyfind.com/au3/upgrade/latest.html

All 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 by aGorilla
Link to comment
Share on other sites

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.).

Link to comment
Share on other sites

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

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...