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.

85 lines
2.2 KiB

  1. '
  2. L_Welcome_MsgBox_Message_Text = "This script demonstrates how to refresh 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. snapins.Add "{975797FC-4E2A-11D0-B702-00C04FD8DBF7}" ' eventlog snapin
  32. snapins.Add "{58221c66-ea27-11cf-adcf-00aa00a80033}" ' the services snap-in
  33. ' Select the root of "EventViewer" snapin.
  34. Set rootnode = namespace.GetRoot
  35. Set SnapNode1 = namespace.GetChild(rootnode)
  36. view.ActiveScopeNode = SnapNode1
  37. ' Get the "Application Log" node and refresh it (Temp selection).
  38. Set SnapNode1 = namespace.GetChild(SnapNode1)
  39. view.RefreshScopeNode SnapNode1
  40. ' Refresh "SystemLog" node in ListView
  41. view.Select view.ListItems.Item(1)
  42. view.RefreshSelection
  43. ' Now select "Application Log" node and refresh it.
  44. view.ActiveScopeNode = SnapNode1
  45. view.RefreshScopeNode
  46. ' Select the 5th log event and refresh it.
  47. view.Select view.ListItems.Item(4)
  48. view.RefreshSelection
  49. ' Select the services snapin root node.
  50. Set SnapNode1 = namespace.GetChild(rootnode)
  51. Set SnapNode1 = namespace.GetNext(SnapNode1)
  52. view.ActiveScopeNode = SnapNode1
  53. ' Refresh service 2
  54. view.Select view.ListItems.Item(5)
  55. view.RefreshSelection
  56. Set mmc = Nothing
  57. ' ********************************************************************************
  58. ' *
  59. ' * Welcome
  60. ' *
  61. Sub Welcome()
  62. Dim intDoIt
  63. intDoIt = MsgBox(L_Welcome_MsgBox_Message_Text, _
  64. vbOKCancel + vbInformation, _
  65. L_Welcome_MsgBox_Title_Text )
  66. If intDoIt = vbCancel Then
  67. WScript.Quit
  68. End If
  69. End Sub