Introduction
B&C needs auto-updating functionality for its VB6 database interface software, called ES2. Ideally, users will login & the application will check to see if it needs to grab a new binary stored in the DB. The RDBMS is SQL2005+.
Potential steps
Three executable names, but only two should exist at a time; all operations should be local to a given directory.
es2_v8.exe
es2_v8_old.exe (_old)
es2_v8_new.exe (_new)
es2_v8.exe starts
- if
_new exists, goto 4
- download executable (or exit if no updated version available)
- if exe image is on a UNC share or networked drive, error: "A new version of ES2 is available, but will not be downloaded because you are running ES2 from the network."
- if the CRC doesn't match
@new_crc, error
- if the executable is the same as the currently executing image, error
- if the executable is the same as
_new, error
- save as
_new
- tell all
es2_v8.exe instances to exit (and exit current instance)
- launch C program which waits N seconds for all
es2_v8.exe instances to close
- forcibly terminate
es2_v8.exe "stuck" processes that do not have top-level windows open (if this isn't too hard to figure out)
- if all close, delete
_old, rename es2_v8.exe to _old, and rename _new to es2_v8.exe
- otherwise, error: "Please close all ES2 windows and then restart it. If this does not work, please restart your machine and then start ES2."
- launch the newly renamed
es2_v8.exe
Detecting when a new version is needed
Call a stored procedure with the following arguments:
@current_version pull from exe properties
@current_crc (or some checksum)
@exe_is_on_network_drive if 1, forces @new_binary to be null
@new_crc OUTPUT null if no new binary available
@new_binary OUTPUT null or contains the new binary
Note that the stored procedure itself will have access to:
host_name()
user_name()
db_name()