home *** CD-ROM | disk | FTP | other *** search
/ Chip 1998 February / CHIP_2_98.iso / software / pelne / optionp / mts4.cab / WSH_InstDLLCLI.vbs < prev    next >
Text File  |  1997-11-14  |  4KB  |  123 lines

  1. ' Filename: InstDLLCLI.vbs
  2. '
  3. ' Description: Sample VB Script that creates an empty package and installs the Sample Bank components into it
  4. '
  5. ' This file is provided as part of the Microsoft Transaction Server Samples
  6. ' See the MTS Software Development Kit for more information on Scriptable Administration Objects
  7. '
  8. ' THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT 
  9. ' WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, 
  10. ' INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES 
  11. ' OF MERCHANTABILITY AND/OR FITNESS FOR A  PARTICULAR 
  12. ' PURPOSE.
  13. '
  14. ' Copyright (C) 1997 Microsoft Corporation, All rights reserved
  15. '
  16. ' Use: InstDLLCLI.vbs "dll path"
  17. ' Ex:  InstDLLCLI.vbs "C:\Program Files\MTX\Packages\Samples"
  18.  
  19. ' Get arguments
  20. Dim objArgs
  21. Set objArgs = WScript.Arguments
  22.  
  23. ' Set up path names
  24. Dim packageName
  25. packageName = "Sample Bank"
  26. Path = objArgs(0)
  27.  
  28. ' First, we create the catalog object
  29. Dim catalog
  30. Set catalog = CreateObject("MTSAdmin.Catalog.1")
  31.  
  32. ' Then we get the packages collection
  33. Dim packages
  34. Set packages = catalog.GetCollection("Packages")
  35. packages.Populate
  36.  
  37. ' Remove all packages that go by the same name as the package we wish to install
  38. numPackages = packages.Count
  39. For i = numPackages - 1 To 0 Step -1
  40.     If packages.Item(i).Value("Name") = packageName Then
  41.         packages.Remove (i)
  42.     End If
  43. Next
  44.  
  45. ' Commit our deletions
  46. packages.SaveChanges
  47.  
  48. ' Add a new package
  49. Dim newPackage
  50. Set newPackage = packages.Add
  51. newPackage.Value("Name") = packageName
  52. newPackage.Value("SecurityEnabled") = "N"
  53.  
  54. ' Commit new package
  55. packages.SaveChanges
  56.  
  57. ' Refresh packages
  58. packages.Populate
  59.  
  60. ' Get components collection for new package
  61. Dim components
  62. Set components = packages.GetCollection("ComponentsInPackage", newPackage.Value("ID"))
  63.  
  64. ' Install components
  65. Dim util
  66. Set util = components.GetUtilInterface
  67.  
  68. ' VB and VC
  69. dllPath = Path & "vbacct.dll"
  70. util.InstallComponent dllPath, "", ""
  71. dllPath = Path & "vcacct.dll"
  72. util.InstallComponent dllPath, "", ""
  73.  
  74. ' Java:  i386 only
  75. util.ImportComponentByName "Bank.Account.VJ"
  76. util.ImportComponentByName "Bank.MoveMoney.VJ"
  77. util.ImportComponentByName "Bank.GetReceipt.VJ"
  78. util.ImportComponentByName "Bank.UpdateReceipt.VJ"
  79.  
  80. ' Refresh components
  81. components.Populate
  82.  
  83. ' Iterate through the components and change the transaction attributes
  84. numComponents = components.Count
  85.  
  86. Dim component
  87. Dim progName
  88.  
  89. For i = numComponents - 1 To 0 Step -1
  90.     Set component = components.Item(i)
  91.     progName = component.Value("ProgID")   
  92.  
  93.     If progName = "Bank.Account" Or progName = "Bank.Account.VC" Then
  94.         component.Value("Transaction") = "Required"
  95.     End If
  96.  
  97.     If progName = "Bank.MoveMoney" Or progName = "Bank.MoveMoney.VC" Then
  98.         component.Value("Transaction") = "Required"
  99.     End If
  100.    
  101.     If progName =  "Bank.GetReceipt" Or progName =  "Bank.GetReceipt.VC" Then
  102.         component.Value("Transaction") = "Supported"
  103.     End If
  104.     
  105.     If progName =  "Bank.UpdateReceipt" Or progName =  "Bank.UpdateReceipt.VC" Then
  106.         component.Value("Transaction") = "Requires New"
  107.     End If
  108.     
  109.     If component.Value("ProgID") = "Bank.CreateTable" Then
  110.         component.Value("Transaction") = "Not Supported"
  111.     End If
  112. Next
  113.  
  114. ' Commit the changes to the components
  115. components.SaveChanges
  116.  
  117. ' Create the 'Managers' role in the package
  118. Dim rolesInPack
  119. Dim newRole
  120. Set rolesInPack = packages.GetCollection("RolesInPackage", newPackage.Value("ID"))
  121. Set newRole = rolesInPack.Add
  122. newRole.Value("Name") = "Managers"
  123. rolesInPack.SaveChanges