On 24/04/2011 17:18, Christopher Faylor wrote: > On Sun, Apr 24, 2011 at 02:05:57PM +0100, Jon TURNEY wrote: >> Updating setup.exe has 3 stages: >> 1) Download updated setup.exe to a temporary location >> 2) Execute that temporary copy of setup.exe with --copy-to instructing >> it to copy itself over the setup.exe to be updated >> 3) Execute the updated setup.exe with --remove-from instructing it >> to delete the temporary copy >> >> A named mutex is used to ensure setup exits from each stage before >> the next stage can start. >> >> Unfortunately, at the moment, we don't usefully check the setup version >> number >> until after we have downloaded and parsed setup.ini, which is perhaps a bit >> late to offer to update setup.exe >> >> v2: Address comments from Dave Korn >> Properly quote arguments to ensure spaces in paths are handled safely >> Place the setup URL in a string resouce >> >> 2011-03-29 Jon TURNEY <[email protected]> >> >> * res.rc (IDS_OLD_SETUP_VERSION): Change text to offer to download >> new version of setup. >> (IDS_SETUP_URL): Added string resource. >> * resource.h (IDS_SETUP_URL): Added resource identifier. >> * main.cc (wait_for_exit, self_update_remove_from, >> self_update_copy_to, WinMain): Add -copy-to and --remove-from options >> for self-update process. >> * ini.cc (self_update_download): New function to download updated >> setup. >> (do_ini_thread): Prompt to download updated setup if a newer >> version exists. Return a result indicating what should happen >> next. >> * threebar.h (PropertyPage::OnFinish): Add an implementation of >> OnFinish virtual function for this class. >> * threebar.cc (OnFinish): Ditto. >> (OnMessageApp): Setup should finish on >> WM_APP_SETUP_INI_DOWNLOAD_COMPLETE >> if an updated setup was downloaded. >> >> 2011-03-29 Jon TURNEY <[email protected]> >> >> * include/getopt++/DefaultFormatter.h (DefaultFormatter): Fix option >> string >> formatting when it has no short option. > > Sounds wonderful but couldn't you just rename the original setup.exe out > of the way, copy a new version over it in place, and then re-execute?
I'm just following a sequence of actions which a bit of google research found other people had successfully used. what you suggest seems like it should work, although I'd perhaps be a bit wary of assuming that MoveFile() on the running executable works always.
