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.

110 lines
3.0 KiB

  1. '
  2. L_Welcome_MsgBox_Message_Text = "This script demonstrates how to access list view text 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 MySnapin
  18. Dim CellData
  19. Dim Flags
  20. ' Following are snapin exposed objects.
  21. Dim ScopeNodeObject
  22. Dim ResultItemObject
  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 "{18731372-1D79-11D0-A29B-00C04FD909DD}" ' Sample 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 "User Data".
  38. Set SnapNode1 = namespace.GetChild(SnapNode1)
  39. view.ActiveScopeNode = SnapNode1
  40. ' Now Select/Deselect nodes in succession.
  41. Set Nodes = view.ListItems
  42. view.Select Nodes(1)
  43. 'view.Deselect Nodes(1)
  44. view.Select Nodes(2)
  45. CellData = view.CellContents(0, 0)
  46. MsgBox("Cell(0,0) = " + CellData)
  47. CellData = view.CellContents(3, 2)
  48. MsgBox("Cell(3,2) = " + CellData)
  49. ' Uncomment below line, will fail as it addresses non-existent cell.
  50. 'CellData = view.CellContents(4, 3)
  51. ' ExportList(filename, bSelected, bTabDelimited, bUnicode)
  52. ExportListOptions_Default = 0
  53. ExportListOptions_TabDelimited = 2
  54. ExportListOptions_Unicode = 1
  55. ExportListOptions_SelectedItemsOnly = 4
  56. Flags = ExportListOptions_TabDelimited
  57. view.ExportList "c:\temp\ansi_all.txt", Flags
  58. Flags = ExportListOptions_TabDelimited Or ExportListOptions_Unicode
  59. view.ExportList "c:\temp\unicode_all.txt", Flags
  60. view.ExportList "c:\temp\ansi_all.csv", ExportListOptions_Default
  61. view.ExportList "c:\temp\unicode_all.csv", ExportListOptions_Unicode
  62. Flags = ExportListOptions_SelectedItemsOnly Or ExportListOptions_TabDelimited
  63. view.ExportList "c:\temp\ansi_sel.txt", Flags
  64. Flags = ExportListOptions_SelectedItemsOnly Or ExportListOptions_TabDelimited Or ExportListOptions_Unicode
  65. view.ExportList "c:\temp\unicode_sel.txt", Flags
  66. view.ExportList "c:\temp\ansi_sel.csv", ExportListOptions_SelectedItemsOnly
  67. Flags = ExportListOptions_SelectedItemsOnly Or ExportListOptions_Unicode
  68. view.ExportList "c:\temp\unicode_sel.csv", Flags
  69. view.ExportList "c:\temp\defaultparm_all"
  70. Set mmc = Nothing
  71. ' ********************************************************************************
  72. ' *
  73. ' * Welcome
  74. ' *
  75. Sub Welcome()
  76. Dim intDoIt
  77. intDoIt = MsgBox(L_Welcome_MsgBox_Message_Text, _
  78. vbOKCancel + vbInformation, _
  79. L_Welcome_MsgBox_Title_Text )
  80. If intDoIt = vbCancel Then
  81. WScript.Quit
  82. End If
  83. End Sub