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.

83 lines
2.1 KiB

  1. '
  2. L_Welcome_MsgBox_Message_Text = "This script demonstrates how to add/remove snapins 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 Services
  18. Dim Eventlog
  19. Dim OtherData
  20. 'get the various objects we'll need
  21. Set mmc = wscript.CreateObject("MMC20.Application")
  22. Set frame = mmc.Frame
  23. Set doc = mmc.Document
  24. Set namespace = doc.ScopeNamespace
  25. Set rootnode = namespace.GetRoot
  26. Set views = doc.views
  27. Set view = views(1)
  28. Set snapins = doc.snapins
  29. mmc.UserControl = true
  30. Set Eventlog = snapins.Add("Event Viewer")
  31. Set Services = snapins.Add("Services", EventLog)
  32. OtherData = "Num Snapins: " & snapins.Count
  33. intRet = MsgBox(OtherData, vbInformation, "Snapins count")
  34. ' Enumerate the snapins collection and print the about info for each snapin.
  35. For Each snapin in snapins
  36. SnapinName = snapin.Name
  37. OtherData = "Vendor : " + snapin.Vendor
  38. OtherData = OtherData + ", Version : " + snapin.Version
  39. OtherData = OtherData + ", CLSID : " + snapin.SnapinCLSID
  40. ' intRet = MsgBox(OtherData, vbInformation, "About Information for " & SnapinName)
  41. Next
  42. For i = 1 To snapins.count
  43. Set snapin = snapins.Item(i)
  44. SnapinName = snapin.Name
  45. OtherData = "Vendor : " + snapin.Vendor
  46. OtherData = OtherData + ", Version : " + snapin.Version
  47. OtherData = OtherData + ", CLSID : " + snapin.SnapinCLSID
  48. intRet = MsgBox(OtherData, vbInformation, "About Information for " & SnapinName)
  49. Next
  50. snapins.Remove(EventLog)
  51. Set mmc = Nothing
  52. ' ********************************************************************************
  53. ' *
  54. ' * Welcome
  55. ' *
  56. Sub Welcome()
  57. Dim intDoIt
  58. intDoIt = MsgBox(L_Welcome_MsgBox_Message_Text, _
  59. vbOKCancel + vbInformation, _
  60. L_Welcome_MsgBox_Title_Text )
  61. If intDoIt = vbCancel Then
  62. WScript.Quit
  63. End If
  64. End Sub