Member Avatar for Thew

Hi,
I need to resolve this problem:
Is there any way, how to replace currently runned application with a new version?
Like through uninstallation, when uninstall.exe is removed by itself.

I have dialog with AutoUpdate in my application. It's small application so I don't want to make another autoupdate.exe file. So I need to replace current application with a newer one downloaded from the Internet.

Any solutions?

Well, no one else is responding so here's my take. Mind you, I've never tried to do this so I can't claim I know everything there is to know about it.

Windows is pretty particular about not permitting the exe file to be modified while the program is running. So, there are three options I can see (the first two are common, and I don't know if the last would really work or not [for those same technical restrictions]).

  1. Download the updates, then use the run-once registry key (to effect the actual update and launch the new application when Windows is restarted), and tell the user he must restart Windows for the update to take effect.
  2. Keep all the code that can be updated in DLLs that the application uses explicitly (with the LoadLibrary() API function). To update, download the replacements, use FreeLibrary(), replace the DLLs, and use LoadLibrary() again on the new DLLs. This method isn't quite as flexible as the first, obviously, but would suffice for a large number of tasks.
  3. Launch a script or another application that knows how to update. Terminate yourself. The launched app makes the required changes, then starts the new version of the program and terminates itself, leaving the new program running happily.

Hope this helps.

Member Avatar for Thew

Yes, it helps. Thanks

Member Avatar for Thew

Yes, it helps. Thanks.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.