Automating Enumerating Through Installed MTS Packages to Update Properties

To enumerate through installed packages in order to update properties in the package named “My Package”:
  1. Declare the objects that you will be using to enumerate through installed packages to update package properties.
    Private Sub BrowseUpdate_Click()
    Dim catalog As Object
    Dim packages As Object
    Dim pack As Object
    Dim componentsInNewPack As Object
    Dim util As Object
  2. Use the On Error statement to handle run-time errors if a method returns a failure HRESULT. You can test and respond to MTS trappable errors using the On Error statement and the Err object.
    On Error GoTo failed
  3. Call the CreateObject method to instantiate the Catalog object. Retrieve the Packages collection by calling the GetCollection method. Then call the Populate method to fill the collection with packages from the catalog.
    Set catalog = CreateObject("MTSAdmin.Catalog.1")
    Set packages = catalog.GetCollection("Packages")
    packages.Populate
  4. Enumerate through a collection to find the package named “My Package.” When “My Package” is located, set the SecurityEnabled property to “Y.” Call the SaveChanges method to save the property update for the package.
    For Each pack In packages
            If pack.Name = "My Package" Then
                pack.Value("SecurityEnabled") = "Y"
                Exit For
            End If
        Next
    packages.SaveChanges
               
        Exit Sub
  5. Use the Err object to display an error message if the installation of the package fails.
    failed:
        MsgBox "Failure code " + Str$(Err.Number)
    
     End Sub

See Also

MTS Administration Objects, MTS Collection Types, MTS Administration Object Methods, Automating Advanced MTS Administration with Visual Basic