How to programmatically update the source list for an installed Windows Installer package (297168)



The information in this article applies to:

  • Microsoft Windows Installer 1.1
  • Microsoft Windows Installer 1.2
  • Microsoft Windows Installer 2.0

This article was previously published under Q297168

SUMMARY

The Windows Installer maintains a list of network or URL source paths to an installed product's installation package. This is known as the "source list." If the installation source files are needed, the Installer will attempt to use the last known available path. This is known as the "LastUsedSource". If the LastUsedSource is not available or not valid, the Installer locates a source by enumerating the source list and uses the first accessible location that it finds. It may be necessary to change the Windows Installer source list for an installed product. This may be necessary for proper maintenance and source resiliency.

This article explains how to use Microsoft Visual Basic Script and the Windows Installer automation interface to change the source list.

MORE INFORMATION

The Installer object of the automation interface exposes three methods that are useful in manipulating the source list of an installed product. These methods are AddSource, ClearSourceList, and ForceSourceListResolution.

AddSource method:

Adds a source to the list of valid network sources in the source list.

Syntax:

object.AddSource(Product As String, User As String, Source As String)


Parameters:

object
    Installer object.

Product
    The product code for the package to be updated.

User
    The user name for a per-user installation; an empty string for a per-computer installation.

Source
    The new source to be added.


Return value:

None


ClearSourceList method:

Removes all network sources from the source list.

Syntax:

object.ClearSourceList(Product As String, User As String)


Parameters:

object
    Installer object.

Product
    The Product Code for the package to be updated.

User
    The user name for a per-user installation; an empty string for a per-computer installation.


Return Value:

None


ForceSourceListResolution method:

Forces the Installer to search the source list for a valid product source the next time a source is needed.

Syntax:

object.ForceSourceListResolution(Product As String, User As String)


Parameters:

object
    Installer object.

Product
    The product code for the package to be updated.

User
    The user name for a per-user installation; an empty String for a per-computer installation.


Return Value:

None

All three of these methods require the product code for the product whose source list will be manipulated and the user name for a per-user installation or empty string for a per-computer installation.

Writing the VBScript

The first step in automating the Windows Installer is to instantiate an instance of the Installer object. This can be done by using the WindowsInstaller.Installer ProgID:
Dim wiInstaller
Set wiInstaller = CreateObject("WindowsInstaller.Installer")
				

Once the Installer object has been instantiated, then the source list can be manipulated through the use of one of the methods described previously.

The following are sample code blocks for each of the source list manipulation methods. The sample code demonstrates manipulation of the source list for Microsoft Office 2000 Premium for a per-computer installation.

AddSource
wiInstaller.AddSource "{00000409-78E1-11D2-B60F-006097C998E7}", "", "\\server1\share\adminpoint"
wiInstaller.AddSrouce "{00000409-78E1-11D2-B60F-006097C998E7}", "", "\\server2\share\adminpoint"
				

ForceSourceListResolution
wiInstaller.ForceSourceListResolution "{00000409-78E1-11D2-B60F-006097C998E7}", ""
				


Modification Type:MajorLast Reviewed:3/15/2005
Keywords:kbMSCCSearch kbPubTypeKC kbhowto KB297168