A
A
apiwi2020-05-13 01:31:00
Python
apiwi, 2020-05-13 01:31:00

How to automatically update the program when it starts?

There is a scomp code in .exe, how can I auto-update the program when it starts? What lines to add? Let's say that the new code is downloaded via a direct link. In the internet clambered, plainly without explanation. Thanks for your help right away.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey Pankov, 2020-05-13
@apiwi

What exactly don't you understand?
When the program starts, it makes an HTTPS GET request using a pre-wired url. If it follows from the headers that this version of the program is not needed, then you can break the connection and not receive the update file itself. The same can be achieved with two requests: the first is HEAD, and the second, if necessary, is GET.
If a new version is downloaded, you need to check its checksum and, very preferably, its signature. But if you have https, then you don’t have to mess with the signature.
Next, you need to run a shell script in a separate process, which will wait for the completion of the old program and then launch a new one.
On this, the old program completes its work.
As soon as the script sees that the old one has closed, it immediately replaces the file and launches a new one.
If something went wrong, then you can write a message about the problem to a file and the re-launched old program, seeing this message, will not try to update again to that version, because "something went wrong", but will wait for a new one.
There are many options here. Probably there are ready-made libraries that are sharpened to do this. They would have to be created if they did not exist, which means that they most likely already exist and in abundance. Look for ready-made solutions.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question