Platform SDK: Transaction Server

Automating MTS Package Export

[This product will work only on Windows NT 4.0 versions and earlier. For Windows 2000 and later, see COM+ (Component Services).]

To export a package named “test.pak”:

  1. Declare the objects that you will be using to export a package.
    Dim catalog As Object
    Dim packages 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. Call the Populate method to fill the package with data from the catalog.
    Set catalog = CreateObject("MTSAdmin.Catalog.1")
    Set packages = catalog.GetCollection("Packages")
    packages.Populate
  4. Enumerate through the Packages collection to find the package named “My Package.” Once that package is located, instantiate the package utility object and call the ExportPackage method.
    For Each pack In packages
            If pack.Name = "My Package" Then
                Set util = packages.GetUtilInterface
                util.ExportPackage pack.Key, "c:\test.pak", 0
                Exit For
            End If
        Next
              
    Exit Sub
  5. Use the Err object to display an error message if the installation of the component fails.
    failed:
        MsgBox "Failure code " + Str$(Err.Number)
    
    End Sub

See Also

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