Self updating software

Posted by / 17-Mar-2016 05:03

How would you handle updating an exe in an environment such as a Terminal Server where there are multiple users all running the same exe? For updating I use a zipped package that actually contains the little application to perform the update it self.One user might say OK, but what about the other users who are still running the application? It would be better, imho, if you created a custom MSBuild action incrementing the version number appropriately and then FTPing the new file on the Linux server. So when new update is found it downloads it, unpacks it, and executes the updater placed in the package.When the wait completes it can replace all executables and dlls that were previously locked.You'll need to use the following Windows APIs: - Wait For Single Object: using this the updater doesn't need to test for the main application in a loop. - Duplicate Handle: the main application needs to duplicate its own process handle for SYNCHRONIZE access in order to allow another process to wait for it. Terminate; end; The Update YYY program is a non visual program that waits a little time (for the main program to actually terminate), copies the current executable to a backup file, moves the _update version in place, and executes the new main program.This pre-loader also checks and updates some dll's and templates in the users profile.Also, a log is written of all users that have updated, just so we can check.We have an option to force a specific user to re-install an update in case the program gets corrupted ('the program' being an Access database in this case, the pre-loader is written in Delphi).

I'm using this procedure in application with 6 additional DLLs and it proves working over a year and a half. We use a similar setup to deploy our application, except that the initial downloaded file is an xml file with all the metadata we need to decide to update the file.

procedure Close Main App makes sure that main application is closed.

This also works if application is using some DLL(s) part of it.

- Create Process: the updater needs to be created with Create Process because the process handle of the newly created process is required by Duplicate Handle.

The major issue is the need of interprocess synchronization to pass the duplicated handle.

self updating software-60self updating software-81self updating software-85

You can't pass the handle in the command line because it'll be available only after the process starts. To pass the list of updates you may use the command line, a temporary file, interprocess synchronization etc.

One thought on “self updating software”