We are trying to push updates to multiple servers at once and my manager has found that it is possible to rename running .exe file. Using that knowledge he wants to rename a running exe and copy over a new version of said exe such that anyone running their in memory copy of foo.exe are fine and anybody who opens a shortcut pointing to foo.exe will get a new copy with updates applied.
I guess I need to clarify, He doesn't expect the old copy to magically update, he just expects them to keep running the old copy until they open the exe again, in which case it will then open the new one that has the name of the old one.
It sometimes throws an exception that the file is in use on his program but if he tries renaming it in a loop it will eventually succeed. On my machine I have yet to be able to get it to work even in a loop.
My first and main question is this: Is it ever acceptable to do this. Should renaming a running executable ever be a valid scenario?
Secondly, if it is a valid scenario then how could one reliably do this? Our current thoughts are try a bunch of times using File.Move (C#) to do a rename and if it doesn't work then write out to an error log so it can be handled manually.
launcher.exe
andmyapp.exe
the client executelauncher.exe
and it downloadmyapp.exe
to the client temp folder and then execute it. So the myapp.exe is running locally on all computers, so you can replace themyapp.exe
. they will get the update on the next launch. – CrimSafeDelete()
function that generates a unique name with a.delme
extension and renames the file to that, and aSafeCleanup()
funcion that tries to detete all the.delme
files in a directory. I wonder if it work on Linux... – Roye