home *** CD-ROM | disk | FTP | other *** search
/ Chip 1999 September / CHIPCD_9_99.iso / software / uaktualnienia / OptionPackPL / MTS4.CAB / WSH_InstDLL.vbs < prev    next >
Text File  |  1998-04-27  |  3KB  |  115 lines

  1. ' Filename: InstDLL.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. Dim packageName
  17. packageName = "Sample Bank"
  18. Path = "C:\Program Files\MTX\Packages\"
  19.  
  20. ' First, we create the catalog object
  21. Dim catalog
  22. Set catalog = CreateObject("MTSAdmin.Catalog.1")
  23.  
  24. ' Then we get the packages collection
  25. Dim packages
  26. Set packages = catalog.GetCollection("Packages")
  27. packages.Populate
  28.  
  29. ' Remove all packages that go by the same name as the package we wish to install
  30. numPackages = packages.Count
  31. For i = numPackages - 1 To 0 Step -1
  32.     If packages.Item(i).Value("Name") = packageName Then
  33.         packages.Remove (i)
  34.     End If
  35. Next
  36.  
  37. ' Commit our deletions
  38. packages.SaveChanges
  39.  
  40. ' Add a new package
  41. Dim newPackage
  42. Set newPackage = packages.Add
  43. newPackage.Value("Name") = packageName
  44. newPackage.Value("SecurityEnabled") = "N"
  45.  
  46. ' Commit new package
  47. packages.SaveChanges
  48.  
  49. ' Refresh packages
  50. packages.Populate
  51.  
  52. ' Get components collection for new package
  53. Dim components
  54. Set components = packages.GetCollection("ComponentsInPackage", newPackage.Value("ID"))
  55.  
  56. ' Install components
  57. Dim util
  58. Set util = components.GetUtilInterface
  59.  
  60. ' VB and VC
  61. dllPath = Path & "vbacct.dll"
  62. util.InstallComponent dllPath, "", ""
  63. dllPath = Path & "vcacct.dll"
  64. util.InstallComponent dllPath, "", ""
  65.  
  66. ' Java:  i386 only
  67. util.ImportComponentByName "Bank.Account.VJ"
  68. util.ImportComponentByName "Bank.MoveMoney.VJ"
  69. util.ImportComponentByName "Bank.GetReceipt.VJ"
  70. util.ImportComponentByName "Bank.UpdateReceipt.VJ"
  71.  
  72. ' Refresh components
  73. components.Populate
  74.  
  75. ' Iterate through the components and change the transaction attributes
  76. numComponents = components.Count
  77.  
  78. Dim component
  79. Dim progName
  80.  
  81. For i = numComponents - 1 To 0 Step -1
  82.     Set component = components.Item(i)
  83.     progName = component.Value("ProgID")   
  84.  
  85.     If progName = "Bank.Account" Or progName = "Bank.Account.VC" Then
  86.         component.Value("Transaction") = "Required"
  87.     End If
  88.  
  89.     If progName = "Bank.MoveMoney" Or progName = "Bank.MoveMoney.VC" Then
  90.         component.Value("Transaction") = "Required"
  91.     End If
  92.    
  93.     If progName =  "Bank.GetReceipt" Or progName =  "Bank.GetReceipt.VC" Then
  94.         component.Value("Transaction") = "Supported"
  95.     End If
  96.     
  97.     If progName =  "Bank.UpdateReceipt" Or progName =  "Bank.UpdateReceipt.VC" Then
  98.         component.Value("Transaction") = "Requires New"
  99.     End If
  100.     
  101.     If component.Value("ProgID") = "Bank.CreateTable" Then
  102.         component.Value("Transaction") = "Not Supported"
  103.     End If
  104. Next
  105.  
  106. ' Commit the changes to the components
  107. components.SaveChanges
  108.  
  109. ' Create the 'Managers' role in the package
  110. Dim rolesInPack
  111. Dim newRole
  112. Set rolesInPack = packages.GetCollection("RolesInPackage", newPackage.Value("ID"))
  113. Set newRole = rolesInPack.Add
  114. newRole.Value("Name") = "Managers"
  115. rolesInPack.SaveChanges