Page 1 of 1

EXE Form - overwrite itself

Posted: Tue Sep 25, 2018 1:59 am
by ALIENQuake
Hello,

I have prepared very simple autoupdate concept:
1. Read remote json file, check value of the version key, compare it with FileVersionInfo from exe file
2. If they don't match, download executable and overwrite itself

But dealing with this when script is packaged as exe is major pain: the exe file is blocked from overwrite itself because the process is using it. If I close process, I won't able to execute "copy&overwrite".

If this would be c#, I would use Squierl.Windows or something similar but it's Powershell so I can't. Any way to achieve such simple autoupdate concept?

Re: EXE Form - overwrite itself

Posted: Tue Sep 25, 2018 2:10 am
by jvierra
Simple. Download file to new location. Schedule a job to copy the new file over old file and exit. Job can restart the EXE with new file after copy.

Note that PSS uses a separate executable to do this which is also easy. If a new file is detected start the second exe and exit current version. The "installer" EXE will then copy the file and restart it.

Re: EXE Form - overwrite itself

Posted: Mon Oct 15, 2018 10:13 am
by ALIENQuake
Sorry for late reply, great idea. I've created very simple AutoUpdate application for everyone to use. Everything should be easy to figurue out:
AutoUpdate.zip
(56.04 KiB) Downloaded 188 times

Re: EXE Form - overwrite itself

Posted: Mon Oct 15, 2018 10:20 am
by jvierra
Thanks for the update. Glad you came up with a solution. I frequently embed this technique in applications in many languages as it is simple and clean.