Windows executable replacement strategies

I have a Windows program that should automatically update from the server.

It can already transfer files from the server and update + check files such as DLL plugin files before downloading them.

However, this program also needs to update itself. There are probably several ways to do this, and the most obvious of all online clients is to create an "automatic patcher" that downloads and then runs the client executable. This introduces the problem of the need to update startup, so if there is a more elegant solution, I would like to hear about it.

I have to imagine that there is a way to download the new executable file as a temporary file, say, “client.exe.tmp”, and then start a separate process, waiting for the original client.exe to finish working and then rename / copy the new file on top of it.

Has anyone done this before, and what method did you use to make it work?

+4
source share
2 answers
  • Running exe downloads a new one, puts it somewhere
  • Running exe is renamed to anything (e.g. .exe.tmp)
  • Running exe puts the loaded exe where it works (called the same as the original)
  • Running exe launches a loaded exe
  • The downloaded exe files check the .exe.tmp file, if found, delete it and kill the old running process
  • Done
+8
source

I like the add / remove method for the patcher / maintenance / feature tool. Even if for some reason you need to update something as trivial, I don’t see the "chicken or egg paradox" here, it is rather "one hand washing the other."

  • The application checks the server for updates, if any, check if the patcher is updated, if necessary, the application update patcher.
  • Patcher runs as a separate process, downloads the update, and notifies the application of requests to install it.
  • You agree that the application closes notifications about the patcher, the patcher unpacks the data, replaces exe, does additional things that the new version may need, and launches it and terminates
+1
source

Source: https://habr.com/ru/post/1369071/


All Articles