tags:

views:

183

answers:

4

I would like to produce an executable that could make an update verification before it loads, and then, if there is some update, I would like it to replace its file and then reload.

I think it would be better than to have an "updater" exe separated, because what if the updater has to be updated?

It is not possible for me to have shared folders in the network.

+1  A: 

If you're doing a .NET application and need something that is simple. Microsoft has a click once deployment that does what you're looking for. Before using the ClickOnce deployment, I did development a basic updater. The execution happened, that when the program started, it checked for a new version of the files on a background thread. If there was an update available, it would download on that background thread. If the update was for the updater executable, then I would would replace the executable. Otherwise, I would notify the user that an update was ready to install. They would save their work and click the update button. That would run the updater executable which replaced the files and restarted the program. It was very simple, but didn't do incremental updates well or versioning well. I also provided a rollback feature, so that the files which were replaced, were kept in case the user wanted to rollback to the previous version. I didn't keep a history of versions. Instead I assumed that the last version was a good version.

Sam
+4  A: 

The executable could not replace its own file but it could download the new Exe to a known location or filename within the same directory and then, on exit, kick off a process that switches the file so you'll have the update the next time it runs.

If you think about it, this is a better approach anyway, as you could not be sure that the file download would complete. Even if you could, would you really want to make the user wait until the download completed? No...better to let the download run in the background.

Mark Brittingham
It's a good aproach, the closest to perfection so far :)Got my upvote, if no better answere until tomorrow I'll accept this.Thanks!
Ricardo Acras
Thanks Ricardo. I'll be interested in seeing the other answers as well.
Mark Brittingham
A: 

If you are using the .NET Framework, I highly recommend ClickOnce. It can be set up to perform an update on every execution.

There are a couple ways to get the ClickOnce update to update, so to speak. I'll write a blog post on it one of these days. The idea is to have the update run like normal but then when your application starts display a dialog that the update has changed then redirect the user to download and install the exe again. Sending key commands can automate the process.

DavGarcia
+1  A: 

http://stackoverflow.com/questions/264788/can-i-update-a-exe-that-is-running-closed

Yes, you can have the exefile downloading itself. Just rename the running exe to .bak, download the new exe as .exe, then restart application.

The key here is that you cant download the new version over the old version when the program is running, and the solution is that you CAN rename the running exe and THEN download the new with the same name as the running exe had before the renaming occured. Then its just a verification of the downloaded exe:s size and a restart of the program and you are up and running!

Stefan