×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Automate MTS installation components

Automate MTS installation components

Automate MTS installation components

(OP)

'**************************************************
' This script will install CPS COM components
' Be sure the Setup variables in this section
' are correct.
'
'
' Ed MacDonald
' EdMacDonald@yahoo.com
'**************************************************

Option Explicit

' Trailing slash is required on MTS_Package_Directory
Dim MTS_Package_Name , MTS_Package_Directory, MTS_Package_DLL
MTS_Package_Name = "MyPackage"
MTS_Package_Directory = "C:\Program Files\mts\packages\"
MTS_Package_DLL = "MyPackage.dll"
'"

If MsgBox("This will Install the MTS package '" & MTS_Package_Name & "' overwriting the existing installation.", 1, "Confirm Installation") = 1 Then
Call Install()
End If



Sub Install

'**************************************************
' Declarations & Constants
'**************************************************

Dim CRLF
Dim objFS, currentPath, installPath
Dim mtsCatalog, mtsPackages, pkgUtil

CRLF = Chr(13) & Chr(10)

Set objFS = WScript.CreateObject("Scripting.FileSystemObject")
currentPath = objFS.GetAbsolutePathName(".")
installPath = MTS_Package_Directory & MTS_Package_Name

Set mtsCatalog = CreateObject("MTSAdmin.Catalog.1")
Set mtsPackages = mtsCatalog.GetCollection("Packages")
mtsPackages.populate
Set pkgUtil = mtsPackages.GetUtilInterface

'**************************************************
' Stop IIS
'**************************************************

' MsgBox("Stopping Web Server")
Dim oServer
Set oServer = getObject("IIS://LocalHost/W3svc/1")
oServer.Stop

'**************************************************
' Uninstall Existing Package
'**************************************************

'MsgBox "This will Uninstall the MTS package '" & MTS_Package_Name & "' if it exists.", 1, "Confirm Uninstall"

Dim numPackages, i
numPackages = mtsPackages.Count
For i = numPackages - 1 To 0 Step -1
If mtsPackages.Item(i).Value("Name") = MTS_Package_Name Then
pkgUtil.ShutdownPackage(mtsPackages.Item(i).Value("ID"))
mtsPackages.Remove (i)
End If
Next

' Commit our deletions
mtsPackages.SaveChanges


'**************************************************
' Replace Files in Package Directory
'**************************************************

'MsgBox "Copy: " & currentPath & "\" & MTS_Package_DLL & CRLF & "    To: " & installPath & "\" & MTS_Package_DLL & "?", 1, "Confirm File Copy"

If not objFS.FolderExists(installPath) Then
objFS.CreateFolder(installPath)
End If
objFS.CopyFile currentPath & "\" & MTS_Package_DLL, installPath & "\" & MTS_Package_DLL, True

'**************************************************
' Install New Package
'**************************************************

'MsgBox "This will Install MTS package '" & MTS_Package_Name & "'", 1, "Confirm Install"

' Add a new package
Dim newPackage
Set newPackage = mtsPackages.Add
newPackage.Value("Name") = MTS_Package_Name
newPackage.Value("SecurityEnabled") = "N"

' Commit new package
mtsPackages.SaveChanges

' Refresh packages
mtsPackages.Populate

' Get components collection for new package
Dim mtsComponents
Set mtsComponents = mtsPackages.GetCollection("ComponentsInPackage", newPackage.Value("ID"))
mtsComponents.Populate

' Install components
Dim util, dllPath
Set util = mtsComponents.GetUtilInterface

dllPath = installPath & "\" & MTS_Package_DLL
util.InstallComponent dllPath, "", ""

' Refresh components
mtsComponents.Populate


'**************************************************
' Start IIS
'**************************************************
' MsgBox("Starting Web Server")
' Dim oServer
' Set oServer = getObject("IIS://LocalHost/W3svc/1")
oServer.Start


'**************************************************
' Done
'**************************************************
MsgBox("Done")

End Sub

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close