A question we get a lot here is how exactly our update mechanism works. It’s actually very straightforward. You define your existing software update packages inside our IDE, which saves that information inside an updates.ini file. You then upload both the update installers (patches, single exe’s, whatever you like) and the updates.ini file, overwriting the old INI if any, and you are good to go! The next time a scheduled update check runs, your users will be automatically notified by the InstallAware Web Update Client that new updates are available for download. But what if you want to check for updates each time that your application is launched, and automatically install them if any are available?
As I am fond of saying, InstallAware is extremely flexible. There’s a very simple way to do this. To get started, open the updates script at the MSIcode tab - this is found under the “Include Scripts” heading of the Project Manager which is normally docked to the left of the IDE in the MSIcode tab.
The updates script creates shortcuts for the InstallAware Web Update Client wrapper. If you look at lines 24 and 26 of the standard update script, you’ll see that these shortcuts point to the $UNINSTALLLINK$ pre-defined MSIcode variable. This pre-defined variable points to your setup.exe file as cached on the target system, which acts both as your setup driver, and also the web update client.
Now, in your main setup, instead of creating a shortcut for your application’s EXE file (ex: C:\Program Files\My Software\My Application.exe), create a shortcut for $UNINSTALLLINK$ instead (type this inside the Shortcut to File field), and specify the “/update” command line parameter for the shortcut, which will start setup.exe in web update client mode (instead of the regular maintenance/uninstallation mode).
Also, remember to change the shortcut icon to your application’s icon, so your users won’t be confused with a setup icon in their Start Menu.
Now, every time a user clicks your application’s shortcut in the Start Menu, the web update client will launch, and check for updates! But of course, we still need to fix the web update client so it’ll know to launch the main application after checking for updates. Otherwise, users have no way of running the application, since the Start Menu shortcut doesn’t even point to your application anymore.
This is easy too. Again, on the MSIcode tab, navigate to the updates script.
Search for the “Terminate Installation” command throughout the updates script. I recommend typing Ctrl+F and searching for “Terminate“, and then repeating the search by typing F3. That way you won’t miss anything.
Before each “Terminate Installation” command, insert a “Run Program As” command with the target being your main application file (such as “$TARGETDIR$\my application.exe”), and also setting the working directory to “$TARGETDIR$“.
Copy-paste this command before each “Terminate Installation” command inside the updates script. With this simple trick, your application will launch any time the web update client exits – be it upon user abort, failure, or successful update installation. You’re fully covered since you addressed each script termination point.
What if you want to check if this end-user has not paid her subscription fees and thus updates are not to be made available for her? It’s easy. Set up a web page and call it like I described on my previous post using Download File and Parse String – to find out if your user is eligible for updates. I do this by passing her serial number as a parameter to my custom check_updates.aspx page on the server, and then I read back the response. If the response is “1” the end-user can update but if the response is “0“, the end-user is denied access to the update. When the response is “0” you can place another “Run Program As” and “Terminate Install” command pair, in order to make your program run directly without checking for updates. You should place all of these MSIcode commands at the very top of the updates script, before any actual web update client code runs.
Coming up next: It’s about time to look at some .php and .aspx code, and also MySQL and MS SQL database scripts, for the server back end! Don’t miss it!
Software Design Team Lead
InstallAware Software Corporation