Jump to content

I am writing a AutoUpdater and need a little help


Recommended Posts

I am really close to having a auto-updater done but have hit a snag. This program does a version check and it a newer version exists on a ftp site it will download and install the updates.

The problem I am having is finding a function or call that will close the actual program that is doing the update and shelling to another program at that poiint so the actual update program can be updated.

Yes that was confusing :) I run "update.exe" which downloads the updates to a holding area. One of the uupdates might be update.exe. So now I have all these updates in a holding area and want to close the running update.exe so it can be over written but I need a call or something that will close the running update.exe and start running a "phasetwo.exe" which will copy the files (update.exe included) to the main working directory.

In DOS bat file programming the last line would be "exit nextprogram". Does AutoIt have such a call or function?

Link to comment
Share on other sites

I usually compile the main script and the updater as main.a3x and update.a3x, then have a main.exe which only executes those a3x files.

(look at the helpfile for the command line interface to run a3x files using another script as interpreter)

Because main.exe is very simple (between 2 and ~10 lines in total) it will only need updating when you update your autoit version. And you can update the a3x files while they are running, so update.a3x can update itself, then reboot after.

The added benefit is that you will keep your updates really small as you are not downloading the interpreter each time.

Link to comment
Share on other sites

I knew this was going to be hard to explain :)

I run a compiled script Update.exe which downloads a bunch of files from the internet and saves them in a temp folder. One of the updates downloaded might be update.exe (which is currently running). Now I need to copy all the downloads back to the original working directory. It is going to bomb when it tries to copy update.exe over the top of the already running update.exe because "update.exe is already open".

Run("CopyUpdates.exe") ; copy downloaded files back to working directory

ProcessClose("update.exe")

The above won't work because update.exe is not closed until after it comes back from CopyUpdates. The only thing I can think to try is closing update.exe from withing CopyUpdates but won't closing a parent process from within a child process mess things up?

Link to comment
Share on other sites

The method I described won't allow you to copy over the running exe, but you won't have to as it will be unlikely to need updates.

If you still want to have an exe update itself you're going to need to have a helper process. (I recommend a .bat file, but another autoit exe would work as well)

You don't need to close update.exe from the helper process, you can just call Exit after running the helper process.

Make sure the helper process has a small delay build in, to allow update.exe to exit.

Link to comment
Share on other sites

Thanks Tvern. I am still chewing on your replies. I see where you are comming from need to distrubute (and update) the programs to a large customer base and really don't want to install AutoIt on all of them. It turn they won't be able to run scripts. I need to pick your brain a little further on this helper process. So......

I have download.exe which downloads the updates from the internet and saves them in a temp folder. On of the updates could possibly be download.exe

So.... after running "downloads" I want to run a "update.exe" which will copy the files from that temp folder back to the main folder and overwrite files in the main folder. Is what you are saying similar to what johnmccloud posted? That the last thing I want to do in download.exe is:

Run update.exe

Exit

? Won't download.exe still be running when update.exe starts and won't it fail when copying download.exe over the top of the running download.exe?

Link to comment
Share on other sites

I use a 2-stage process.

The first stage does a file-install of the actual updater, then closes and runs the updater.

if the updater itself needs updating, it will be able to update the first-stage program without a problem, then next time it is run it will use the updated updater embedded within it.

My first-stage prog has some other functions too [tidying up old files etc] but it doesn't have to doa nything if you just want it for updating stuff.

William

Link to comment
Share on other sites

? Won't download.exe still be running when update.exe starts and won't it fail when copying download.exe over the top of the running download.exe?

So do as Tvern said and do a short Sleep() or ProcessWaitClose() or something so download.exe have time to exit before you copy it over.
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...