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.

85 lines
2.3 KiB

  1. '
  2. L_Welcome_MsgBox_Message_Text = "This script demonstrates how to access scriptable objects from snapin thro MMC methods. This uses ExplSnap which is made scriptable."
  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. Dim Name
  23. 'get the various objects we'll need
  24. Set mmc = wscript.CreateObject("MMC20.Application")
  25. Set frame = mmc.Frame
  26. Set doc = mmc.Document
  27. Set namespace = doc.ScopeNamespace
  28. Set rootnode = namespace.GetRoot
  29. Set views = doc.views
  30. Set view = views(1)
  31. Set snapins = doc.snapins
  32. snapins.Add "{99C5C401-4FBE-40ec-92AE-8560A0BF39F6}" ' the Component2Test snapin
  33. ' Get rootnode of the snapin
  34. ' And ask View interface for disp interface.
  35. Set SnapNode1 = namespace.GetChild(rootnode)
  36. view.ActiveScopeNode = SnapNode1
  37. Set ScopeNodeObject = view.SnapinScopeObject
  38. ScopeNodeObject.StringFromScriptToSnapin "StringFromScriptToSnapin"
  39. Name = ScopeNodeObject.Name
  40. MsgBox("ScopeNodeObject.Name =" + Name)
  41. Set ScopeNodeObject = view.SnapinScopeObject(SnapNode1)
  42. ScopeNodeObject.Name = "Name"
  43. Name = ScopeNodeObject.StringFromSnapinToScript
  44. MsgBox("ScopeNodeObject.StringFromSnapinToScript =" + Name)
  45. Set ScopeNodeObject = Nothing
  46. view.Select view.ListItems.Item(1)
  47. Set ResultItemObject = view.SnapinSelectionObject
  48. ResultItemObject.StringFromScriptToSnapin "StringFromScriptToSnapin"
  49. Name = ResultItemObject.Name
  50. MsgBox("ResultItemObject.Name =" + Name)
  51. ResultItemObject.Name = "Name"
  52. Name = ResultItemObject.StringFromSnapinToScript
  53. MsgBox("ResultItemObject.StringFromSnapinToScript =" + Name)
  54. Set mmc = Nothing
  55. ' ********************************************************************************
  56. ' *
  57. ' * Welcome
  58. ' *
  59. Sub Welcome()
  60. Dim intDoIt
  61. intDoIt = MsgBox(L_Welcome_MsgBox_Message_Text, _
  62. vbOKCancel + vbInformation, _
  63. L_Welcome_MsgBox_Title_Text )
  64. If intDoIt = vbCancel Then
  65. WScript.Quit
  66. End If
  67. End Sub