This is the third and the final part of my series about ClickTwice – MSI-based web deployment technology introduced in Add-in Express 2010. In the first article of this series I covered the basics of our MSI-based web deployment, and gave you a step-by-step guidance on creating a new setup project. In part 2, we learnt how to publish the application using the MSI-based web deployment. And now we are going to have a close look at managing your application updates.
Managing application updates
When a new version of the software is ready to be published, you need to create a new version of the setup project. All subsequent steps are described in part 2 of the series. However, to activate the self-updating functionality you need to add some code to your application. Here is a sample code that checks for new updates and initiates the updating process.
private void adxRibbonButton1_OnClick(object sender,
AddinExpress.MSO.IRibbonControl control, bool pressed)
{
if (this.IsMSINetworkDeployed() && this.IsMSIUpdatable())
{
string updateUrl = this.CheckForMSIUpdates();
if (!String.IsNullOrEmpty(updateUrl))
{
if (MessageBox.Show("A new version of the add-in was detected. Would you like to install the update?",
this.AddinName, MessageBoxButtons.YesNo,
MessageBoxIcon.Question) == DialogResult.Yes)
{
string ieFullPath =
Path.Combine(Environment.GetFolderPath(
Environment.SpecialFolder.ProgramFiles),
"Internet Explorer\\iexplore.exe");
this.CreateProcess("\"" + ieFullPath + "\" \"" + updateUrl + "\"");
}
}
}
}
The code is based on three methods.
- IsMSINetworkDeployed – returns True if the application was installed via the MSI-based Web deployment feature.
- IsMSIUpdatable – returns True if the user is permited to update the application. In Vista or Windows 7, it is always True. If the application was installed for all users and the user is not an administartor, the UAC popup will ask for administrator credentials.
- CheckForMSIUpdates – returns an empty string if there are no updates on the server or in the network file share. If a new version of the application is available, the method returns a formatted string: a URL or UNC path; the URL can be a link to setup.exe or the application downloader, or if you set ‘Download page for updates’ in the Preferences dialog, the method returns the web page URL.
In the sample above, we use the CreateProcess method to launch the update URL. It runs Internet Explorer in the same integrity level as the host application. Of course, you can use your own code to initiate updates on the end-user’s PC. E.g. you can use the Process class of the .NET Framework to launch the default browser with the URL provided by the CheckForMSIUpdate method.
Conclusion
ClickOnce is a powerful technology for application deployment. However, it doesn’t possess some useful features of the Windows Installer like Multipart wizard, installation of a COM add-in for all users and running custom actions during the installation process. A combination of the Windows Installer and the Add-in Express Web deployment feature empowers the developer with a simple and flexible tool for deploying and updating MSI-based applications via the Internet.
I believe that Add-in Express Web deployment is an excellent means to simplify the deployment of applications written for Microsoft Office and Internet Explorer. Any ideas and suggestions on improving and extending its functionality are the most welcome and we will undoubtedly take all your feednack into consideration when releasing our future builds.
You may also be interested in:
Add-in Express 2010 MSI-based web deployment – ClickTwice, part 1
Add-in Express 2010 MSI-based web deployment: Publishing the application, part 2






One Comment
In the sample code above, we specified the full path to iexplore.exe (which is the Internet Explorer application) in the CreateProcess method. However, this approach does not work for Internet Explorer 6. In this case you can specify the full path to explorer.exe (which is the Windows Explorer application). Many thanks to Aaron for the suggested workaround!