Using the Software Update Wizard with Dynamically Generated Update Scripts

Overview

Some users have requested the ability to use PHP or similar technology to dynamically generate server update scripts.

There is no problem with this approach, except that you must remember that the Software Update Wizard 'keeps score' of the last update processed by keeping an appropriate record in the WebUpdateSvc4.ini file.

The INI section label it uses by default is the URL of the server update script file. If you are passing parameters from your application to the PHP page which generates the server update script file then the INI section label will contain the parameters that were passed - i.e. the full URL including the parameters.  This may make the url different for each user (because it contains identifying parameters for that user).

You should use the IniSectionID= keyword in order to address this potential issue.   IniSectionID= lets you specify a fixed replacement INI section label.

Examples

If you use a plain PHP script with no parameter, you don't have to change anything to your scripts, just output the text via PHP.


Example:

<?php
echo "[1] \n";
echo "Filename=/webupdate/myapplication.exe\n";
echo "WindowTitle=Your Application\n";
echo "Message=There is an updated version of MyApplication.exe available.
Would you like to install it now?\n";
echo "Importance=Optional\n";
echo "Backup=Yes\n";
?>


What do you gain? You can add any PHP command, for example count the number of updates or mail information to anybody.

Example:

<?php
function countdata()
{
.
}
echo "[1] \n";
echo "Filename=/webupdate/myapplication.exe\n";
echo "WindowTitle=Your Application\n";
echo "Message=There is an updated version of MyApplication.exe available.
Would you like to install it now?\n";
echo "Importance=Optional\n";
echo "Backup=Yes\n";
countdata();
mail(user@domain.com, "Update", "Update called");
?>


This is probably not worth the effort, but when you add parameters to your update call, thing start to get really interesting.

If you don't want to write a second script file to distinguish between automatic updates and user invoked updates, just use one PHP script with a parameter, for example &showversionok .

Example:
<?php
echo "[7]\n";
echo "[Filename=/prophecy/prophecy.exe\n";
echo "[Message=This update will upgrade your Prophecy software to version
2.0\n";
echo "[TargetFolder=C:\Program Files\Prophecy\n";
echo "\n";
$showversionok = $_GET[‘showversionok’];
if($showversionok == 1)
{
echo "[99999]\n";
echo "[Message=You already have the very latest version of Prophecy!\n";
}
?>


If you would like to display a message, if the program is up to date, call the script with the parameter "showversionok=1", otherwise with " showversionok=0 ".

Example:

"http://www.domain.com/update.php?showversionok=1"

As stated above, if you are using parameters, you have to add the keyword " IniSectionID= ", as the Software Update Wizard has to use the URL of your update script without any parameter in order to consistently keep the INI files up to date.


Example:

IniSectionID=http://www.domain.com/update.php

Another useful parameter to send to your script file is the license code of your registered application. This way you can control for example the number of times each code is used for updating and find out about which user has not yet updated the program. You can use the first to block the code after several updates of the same file and the second to inform those users that any update is available.

Credits:

The above PHP notes were kindly contributed by Stefan Meyer-Kahlen of ShredderChess.com. Shredder Classic is a professional computer chess program, nine times world computer chess champion. If you like chess, we recommend paying his site a visit!