Create Windows Service Auto-Updatable

Asked

Viewed 621 times

10

I would like to know the recommended procedure for a Windows service to auto-update.

The main questions are:

  1. After the service download a new version of itself, how to stop the service and restart it with the new version?
  2. What procedures should be adopted so that it is not confused with a malicious process (sign with strong key would be an alternative?)

I also accept (unpaid) library suggestions that perform this function.

  • In the Codeplex Cove finds several alternative.

  • I searched there too, I found nothing to satisfy my need.

  • Surely it will be difficult to find something exact for your case, as your approach has its own specifications. But the infrastructure for you to build your project exists.

  • @rubStackOverflow, there is the possibility to migrate this application to Web . Once performing this procedure just change the DLL for the application to be updated. We usually don’t create Windows Services applications if they have the need for many updates or the update is inherent to the user’s will.

4 answers

4

Have you tried using the Clickonce?

It does not have direct support for installing/updating services, but there are some outlines that can be used as described here or here.

  • It’s an interesting approach but it doesn’t fit in the context of my problem.

3

You can make it download the update to a temporary folder and at the end of the update another executable (can even be a .bat file) move the files and re-export the program.

3


There is no simple way to make a process. Net update itself. It would be something like committing hara-kiri and continuing to live to rebuild yourself. The upgrading process would have to be running on a different Domain and the Domain of the process to be upgraded should be destroyed. My recommendation:
Use an auxiliary process to update.
1) Your service detects the need for updating, downloads the file, starts the auxiliary update process, closes the execution autonomously.
2) The auxiliary process updates and restarts the service, waits for execution validation indication and closes.
Note: You should take advantage to make a backup of the previous version, because if you do not pass the validation of the update the previous version can be replaced in operation.

2

Merge Clickonce and/or Webservice to do this for you

See this page that can help you
The web service should be able to read an XML file that contains all the information of a possible update. I chose to use an XML and not a database, for its simplicity.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.