tsunami

log in
history

VB6 auto-updater

Luke Breuer
2008-05-19 10:53 UTC

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)
  1. es2_v8.exe starts
  2. if _new exists, goto 4
  3. download executable (or exit if no updated version available)
    1. 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."
    2. if the CRC doesn't match @new_crc, error
    3. if the executable is the same as the currently executing image, error
    4. if the executable is the same as _new, error
    5. save as _new
  4. tell all es2_v8.exe instances to exit (and exit current instance)
  5. launch C program which waits N seconds for all es2_v8.exe instances to close
    1. forcibly terminate es2_v8.exe "stuck" processes that do not have top-level windows open (if this isn't too hard to figure out)
    2. if all close, delete _old, rename es2_v8.exe to _old, and rename _new to es2_v8.exe
    3. otherwise, error: "Please close all ES2 windows and then restart it. If this does not work, please restart your machine and then start ES2."
  6. 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()