views:

582

answers:

10

Say I make an .exe file and everything is peachy. Wonderful it works.

Say I worked on a new feature on the software and I want it to be available for people who already have the older version, how can I make the software find my new version, patch it, and then go about it's business.

I can't seem to wrap my head around the issue.

Thank you.

EDIT: I'm sorry for the confusion, but I was meaning a more code-wise answer. Is there something special in my code I should have to allow updating?

For example, if I want to add a new feature, how can I add a "method" to an already packaged .exe? :S That has me in a swivel.

+3  A: 

One idea - you could have a loader application that does the check for you, then if necessary updates the main app's exe before launching it?

David M
+1 Exact approach I've used many times, pretty common method
curtisk
what if you need to update the loader?
Kugel
Then put some code in the next version of the main programme that does this silently as it runs if it needs to?
David M
+8  A: 

A popular solution is to actually have a separate process replace the necessary files.

Have you ever noticed that Firefox has to restart whenever it updates? Well, that is because a separate process (updater.exe) is downloading the files, closing firefox, replacing the files, and then starting firefox again.

edit of course this assumes you're hosting a list of updates online that the updater program can check (an RSS feed, or even a simple text file).

Matt
`CCleaner` [ program to clean your system ], even don't update itself. By clicking on `Update` it just downloads the new setup. now you have to manually install the software again, which ofcourse uninstall the previous version. I don't know why CCleaner programmers say it is an update ;)
Rakesh Juyal
Heh, yea, I would say CCleaner takes more of an 'overhaul' approach.
Matt
A: 

For windows (generally due to windows locking the .exe file while it's being executed)

  • Software determines it needs updating
  • Software runs packaged update executable (at this point Software exits)
  • Update downloads required files into some temp folder
  • Update applies patches
  • Update restarts Software
Sekhat
A: 

Well, the usual way is that your application checks somewhere (usually on the Internet) regularly for new versions. This may be on every startup or once a week or whatever.

There you can simply put for example a text file containing the current version number. If that one would be newer than the version of the installed application you can download an updater (don't forget to sign and check signatures) and install the new version.

Joey
+8  A: 

You need to look at Click Once Deployment.

ClickOnce deployment allows you to publish Windows-based applications to a Web server or network file share for simplified installation. Visual Studio provides full support for publishing and updating applications deployed with ClickOnce. ClickOnce deployment is available for projects created with Visual Basic, Visual C#, and Visual J#, but not for Visual C++.

This creates a downloadable setup exe which you load up to the web. The user either runs this in place or downloads and runs it. This wraps your exe in the code that will check the web location (at a frequency of your choosing) for updates. If it finds one it will install it for the user.

You don't have to make any special changes to your code to enable this. beyond incrementing the version number. Just modify and extend your code as normal, compile, build, package and upload.

ChrisF
We've used Click-Once on a number of applications with 1000+ users and it works like a charm.
Walter
A: 

Make your app occasionally make a request over the web to your webserver. Have that request return a file that contains the version number and a link to the newest version of your installer. If that version number is greater than the version number the currently-running program thinks it is, have your program download the new setup file and launch it.

Cory Petosky
That would make my user have to uninstall, and then reinstall the application to the newest version. Not really what I'm looking for.
Sergio Tapia
Not if you're using a sensible installer.
Cory Petosky
+2  A: 

Usually the process is as follows:

  • the user starts the applicataion
  • the application launches an "updater" (another program)
  • the updater retrieves from the Internet if a newer version exists
  • if that's the case, propose the user to update
  • the users accepts, the updater downlads the new install package (that can be incremental)
  • the updater shuts the application down (or better, asks the user to do it) and launches the new installer.
  • the installation package do the rest

Of course you can have many variation, but this is the basic way to do it.

On Windows, at least, some software install an updater deamon that is always on and checks for new updates of the software it takes care (GoogleUpdater, for example).

Remo.D
A: 

You don't modify your current .exe.

You launch a separate process that downloads a new version of the file. The new version replaces the old version. No modification needed.

roomaroo
A: 

From a code point of view I like to have an approach that consists on a simple interface called IRun and another one called IUpdated:

public interface IRun()
{
  public void Run();
}

public interface IUpdated()
{
  public void Update();
}

Now my main application will just load and "run" a library using reflection which in turns launch the real application.

The main application executable will do this steps:

  1. Read updater.cfg, connect to the provided location and check for updates to the updater.
  2. If there are updates download the updated dlls and updater.cfg
  3. Using reflection load updater.dll and launch Update() method.

The update method does the same steps for updates to the actual application.

Finally

  1. Load "core.dll" and launch the Run() method.

That's of course provided you want to "do it yourself", ClickOnce is actually a very good method too, probably better but gives you less control. The main application executable is simple enough to avoid having to update it itself or should be anyway.

Jorge Córdoba
I would really enjoy being able to study the C# code and techniques that implement this if they are publicly available anywhere. thanks,
BillW
A: 

Use an FTP account for checking the files. Upload your files to FTP server and use an index file with file date and file name.

Your desktop update tool checks the index file and compare it with local files. Get only new and updated files with simple ftp commands.

You can Use Indy Project Components for FTP processes.

drorhan