Automating MTS Package Property Updates on Remote Servers
To update package properties on a remote computer named “remote1”:
-
Declare the objects that you will be using to configure a client (running MTS) to deploy and administrator remote components.
Dim catalog As Object
Dim packages As Object
Dim pack As Object
Dim root As Object
-
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
-
Call the CreateObject method to instantiate the Catalog object. Call the Connect method to access the root collection on the computer named “remote1.” The root collection is a collection object that can be used to access top-level collections on the given computer. The root collection contains no objects and has no properties. Note that the key value is not used when calling GetCollection from a root collection. Get the Packages collection on the remote computer by calling the GetCollection method. Then use the Populate method to fill the packages collection.
Set catalog = CreateObject("MTSAdmin.Catalog.1")
Set root = catalog.Connect("remote1")
Set packages = root.GetCollection("Packages", "")
packages.Populate
-
Set the SecurityEnabled setting to “Y” for “My Package” and save changes to the package collection.
For Each pack In packages
If pack.Name = "My Package" Then
pack.Value("SecurityEnabled") = "Y"
Exit For
End If
Next
packages.savechanges
Exit Sub
-
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