I've been searching for a good solution for 3 days now, but I haven't been able to find any so far. My situation is:
A client has application installed (C++, console Application). The application on start-up will check it's version number with the server and get back or it is up-to-date or that it should download a new version.
If it has to download the new version, I would like to download the new script with Curl to the name say: Application2.exe
However, I want it to replace the old Application.exe which triggered the download of the new version.
My solution was: Application.exe downloads Application2.exe. When downloaded, it should trigger Updater.exe which sleeps for let's say 5 seconds. Within these 5 seconds (or whatever timespan which suites best). Within these 5 seconds, Application.exe has time to shutdown and after 5 seconds the Updater.exe replaces Application.exe with Application2.exe.
Now the update is finished and the client has the newest version installed.
Is this solution possible regarding system locking files, etc?
Good news, you can rename files that are open on Windows (executables and DLLs). The lock prevents you from deleting files, not renaming them.
Application_old.exe
while it's running
Application.exe
Application.exe
This way, you'll have auto-restart after update. I do this myself all the time.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With