Source code of Windows XP (NT5)
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.

102 lines
2.5 KiB

  1. '
  2. L_Welcome_MsgBox_Message_Text = "This script demonstrates how to copy snapin items to clipboard 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 SnapNode1
  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. snapins.Add "{18731372-1D79-11D0-A29B-00C04FD909DD}" ' Sample snapin
  32. snapins.Add "{53D6AB1D-2488-11D1-A28C-00C04FB94F17}" ' Certificates snapin
  33. ' Select sample snapin root
  34. Set rootnode = namespace.GetRoot
  35. Set SnapNode1 = namespace.GetChild(rootnode)
  36. view.ActiveScopeNode = SnapNode1
  37. ' Now select the scope items in LV and try copy
  38. view.Select view.ListItems.Item(1)
  39. view.CopySelection
  40. ' Get "User Data" and try copy on scope item in scope pane (temp selection)
  41. Set SnapNode1 = namespace.GetChild(SnapNode1)
  42. view.CopyScopeNode SnapNode1
  43. ' Now select the "User Data" and try copy once again.
  44. view.ActiveScopeNode = SnapNode1
  45. view.CopyScopeNode
  46. ' Now navigate to the Certificates/Trusted Root Cert/Certificates node
  47. Set SnapNode1 = namespace.GetChild(rootnode)
  48. Set SnapNode1 = namespace.GetNext(SnapNode1)
  49. ' Select certificates root node
  50. view.ActiveScopeNode = SnapNode1
  51. ' Select "Trusted Root cert..." node
  52. Set SnapNode1 = namespace.GetChild(SnapNode1)
  53. Set SnapNode1 = namespace.GetNext(SnapNode1)
  54. view.ActiveScopeNode = SnapNode1
  55. ' Select "Certificates" node
  56. Set SnapNode1 = namespace.GetChild(SnapNode1)
  57. view.ActiveScopeNode = SnapNode1
  58. Set Nodes = view.ListItems
  59. ' Now call copy on LV items
  60. view.Select Nodes(1)
  61. view.CopySelection
  62. view.Deselect Nodes(1)
  63. view.Select Nodes(4)
  64. view.CopySelection
  65. Set mmc = Nothing
  66. ' ********************************************************************************
  67. ' *
  68. ' * Welcome
  69. ' *
  70. Sub Welcome()
  71. Dim intDoIt
  72. intDoIt = MsgBox(L_Welcome_MsgBox_Message_Text, _
  73. vbOKCancel + vbInformation, _
  74. L_Welcome_MsgBox_Title_Text )
  75. If intDoIt = vbCancel Then
  76. WScript.Quit
  77. End If
  78. End Sub