Automating Installation of a Pre-Built MTS Package
To install a pre-built package named “Test.pak” into the MTS Explorer:
-
Declare the objects that you will be using to install a pre-built package.
Private Sub InstallPackage_Click()
Dim catalog As Object
Dim packages As Object
Dim util 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. Retrieve the top level Packages collection by calling the GetCollection method.
Set catalog = CreateObject("MTSAdmin.Catalog.1")
Set packages = catalog.GetCollection("Packages")
-
Instantiate the PackageUtil object, and call the InstallPackage method to install a package named “test.pak.”
Set util = packages.GetUtilInterface
util.InstallPackage "c:\test.pak", "", 0
Exit Sub
-
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