Page 1 of 1

Auto update an exe on failed version check

Posted: Tue Oct 01, 2019 3:54 pm
by Lembasts
Hi,
Let's say I have a compiled PS exe stored on the user's C drive.
When they launch the exe, it first does a version check.
What I would like to do is automatically copy a newer version from a UNC path to replace the local exe if the version check fails.
However if I do the version check, I cannot automatically do a copy command if the version check fails because the exe is in use.
What's the best way to spawn a task that does the copy successfully please?
Thanks
David

Re: Auto update an exe on failed version check

Posted: Tue Oct 01, 2019 4:04 pm
by mxtrinidad
First, the process you're describing won't work. As you mention, the executable is already running.

Now, it may be possible to:
1. Create a background process (if the older version exists) to run outside the executable which could terminate the running process.
2. Then uninstall the executable.
3. And finally, run the installer for the new application.

:)

Re: Auto update an exe on failed version check

Posted: Tue Oct 01, 2019 4:14 pm
by Lembasts
Thanks.
There is no install/uninstall for the app.
Its simply a matter of copying a new exe from a server.

Re: Auto update an exe on failed version check

Posted: Tue Oct 01, 2019 4:45 pm
by Alexander Riedel
Write a cmd file (copyapp.cmd) that copies the app file and starts it again. Execute with CMD /c copyapp.cmd and exit immediately.
You may need some kind of delay in there. Timeout or Start-Sleep if you use PowerShell.
You can of course do the same thing in powershell with a powershell script. Erase the cmd or ps1 one when you app starts and it exists to avoid clutter.
Pretty low tech in a way but it works.