Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

109 lines
3.0 KiB

  1. '
  2. L_Welcome_MsgBox_Message_Text = "This script demonstrates how to delete snapin items from scriptable objects."
  3. L_Welcome_MsgBox_Title_Text = "Windows Scripting Host Sample"
  4. Call Welcome()
  5. ' ********************************************************************************
  6. Dim mmc
  7. Dim doc
  8. Dim snapins
  9. Dim frame
  10. Dim views
  11. Dim view
  12. Dim scopenamespace
  13. Dim rootnode
  14. Dim Nodes
  15. Dim scopenode
  16. Dim SnapNode
  17. Dim ResultItem
  18. Dim MySnapin
  19. ' Following are snapin exposed objects.
  20. Dim ScopeNodeObject
  21. Dim ResultItemObject
  22. 'get the various objects we'll need
  23. Set mmc = wscript.CreateObject("MMC20.Application")
  24. Set frame = mmc.Frame
  25. Set doc = mmc.Document
  26. Set namespace = doc.ScopeNamespace
  27. Set rootnode = namespace.GetRoot
  28. Set views = doc.views
  29. Set view = views(1)
  30. Set snapins = doc.snapins
  31. mmc.UserControl = true
  32. ' Add index snapin & multisel sample
  33. snapins.Add "{95AD72F0-44CE-11D0-AE29-00AA004B9986}" ' index snapin
  34. snapins.Add "{C3D863FF-5135-4CFC-8C11-E7396DA15D03}" ' Multisel sample
  35. ' Get rootnode of the snapin.
  36. Set SnapNode1 = namespace.GetChild(rootnode)
  37. ' Select the root node of the snapin.
  38. view.ActiveScopeNode = SnapNode1
  39. ' Get "System" and delete it (Temp selection and delete).
  40. Set SnapNode1 = namespace.GetChild(SnapNode1)
  41. view.DeleteScopeNode SnapNode1
  42. ' Select "System" and delete it.
  43. view.ActiveScopeNode = SnapNode1
  44. view.DeleteScopeNode
  45. ' Now enumerate and select the "Space Station" node in multi-sel sample.
  46. Set SnapNode1 = namespace.GetChild(rootnode) ' Get the index snapin root
  47. Set SnapNode1 = namespace.GetNext(SnapNode1) ' Get multi-sel root
  48. view.ActiveScopeNode = SnapNode1
  49. ' Get the 4th child of multi-sel root node
  50. Set SnapNode1 = namespace.GetChild(SnapNode1)
  51. Set SnapNode1 = namespace.GetNext(SnapNode1)
  52. Set SnapNode1 = namespace.GetNext(SnapNode1)
  53. Set SnapNode1 = namespace.GetNext(SnapNode1)
  54. view.ActiveScopeNode = SnapNode1
  55. ' Get the child of this "Space Vehicles" node and select it.
  56. Set SnapNode1 = namespace.GetChild(SnapNode1)
  57. view.ActiveScopeNode = SnapNode1
  58. Set Nodes = view.ListItems
  59. view.Select Nodes(1)
  60. view.DeleteSelection
  61. view.Select Nodes(2)
  62. view.Select Nodes(3)
  63. ' Multiselection verb computation has bugs will be fixed.
  64. ' The CMultiSelection object is not computed as LV doesnt have focus.
  65. view.DeleteSelection
  66. view.SelectAll
  67. ' Multiselection verb computation has bugs will be fixed.
  68. ' The CMultiSelection object is not computed as LV doesnt have focus.
  69. view.DeleteSelection
  70. ' Delete "Console Root", this will fail
  71. ' view.DeleteScopeNode rootnode
  72. Set mmc = Nothing
  73. ' ********************************************************************************
  74. ' *
  75. ' * Welcome
  76. ' *
  77. Sub Welcome()
  78. Dim intDoIt
  79. intDoIt = MsgBox(L_Welcome_MsgBox_Message_Text, _
  80. vbOKCancel + vbInformation, _
  81. L_Welcome_MsgBox_Title_Text )
  82. If intDoIt = vbCancel Then
  83. WScript.Quit
  84. End If
  85. End Sub