I'm trying to create an "upgrade" feature in my application. If the program determines that a newer version of the .exe exists on the server, clicking "Upgrade" should replace the currently-running program with the newer program, by copying it off of the server. I can do this with no problem.
The problem arises in that the currently-running program must be overwritten, which obviously cannot be done while it is running. So instead, I unload all of the forms in the project and in the unload method of the last form to be unloaded, I call upgrade.exe (which I created). Upgrade.exe takes care of copying the new one off the server via CopyFile(overwrite = True), and then running the new application via Shell(). Running upgrade.exe is called using the Shell() command, which is the last line of the Unload method, so the main program should terminate immediately after executing this command.
However, even with DoEvents and a Sleep command in the upgrade.exe, I cannot make the first application close before upgrade.exe tries to overwrite it with the application from the server. So obviously the overwriting fails and no "upgrade" occurs.
Any solutions or suggestions? I am using VB6.