Create Windows Self-Upgradable Service

10

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

The main questions are:

  • After the service download a new version of it, how to stop the service and restart it with the new version?
  • What procedures do you take so that it is not confused with a malicious process (signing with strong key would be an alternative?)
  • I also accept suggestions from (unpaid) libraries that perform this function.

        
    asked by anonymous 08.10.2015 / 20:31

    4 answers

    3

    There is no simple way to make a .Net process self-update. It would be something like committing haraquiri and continuing to live to rebuild itself. The updater process would have to be running in a different Domain and the Process Domain to be updated should be destroyed. My recommendation:
    Use an auxiliary process to perform the update.
    1) Your service detects the need to update, downloads the file, starts the auxiliary process of update, terminates the execution autonomously.
    2) The auxiliary process updates and restarts the service, waits for indication of execution validation and closes. Note: You should take advantage of a backup of the previous version, because if it does not pass the update validation the previous version can be put back into operation.

        
    09.09.2017 / 15:59
    4

    Have you tried using ClickOnce ?

    It does not have direct support for the installation / update of services, however there are some outlines that can be used as described here > or here .

        
    16.10.2015 / 15:28
    3

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

        
    18.10.2015 / 02:50
    2

    Interrupt ClickOnce and / or WebService to do this for you

    See this page that can help you Home 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 the simplicity of it.

        
    19.10.2015 / 18:17