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.

90 lines
2.1 KiB

  1. <!--
  2. ******************************************************************
  3. '
  4. ' arrayvalue.wsf
  5. '
  6. ' Purpose: test SWbemPropertyEx::ArrayValue
  7. '
  8. ' Parameters: none
  9. '
  10. ' Returns: 0 - success
  11. ' 1 - failure
  12. '
  13. '*****************************************************************
  14. -->
  15. <job id="WMI ArrayValue Test">
  16. <reference object="WbemScripting.SWbemLocator" version="1.2"/>
  17. <script language="VBScript">
  18. on error resume next
  19. set scriptHelper = CreateObject("WMIScriptHelper.WSC")
  20. scriptHelper.logFile = "c:\temp\arrayvalue.txt"
  21. scriptHelper.loggingLevel = 3
  22. scriptHelper.testName = "WMI ArrayValue"
  23. scriptHelper.testStart
  24. dim ns
  25. dim newClass
  26. ' Connect to the namespace
  27. set ns = GetObject("winmgmts:root\default")
  28. if err <> 0 then
  29. scriptHelper.writeErrorToLog err, "Failed to connect to root\default"
  30. else
  31. scriptHelper.writeToLog "Successful connection to root\default", 2
  32. end if
  33. 'Make a new class
  34. set newClass = ns.Get
  35. if err <> 0 then
  36. scriptHelper.writeErrorToLog err, "Failed to get empty class"
  37. else
  38. scriptHelper.writeToLog "Successful retrieval of empty class", 2
  39. end if
  40. newClass.Path_.Class = "ARRAYVALUE000TEST"
  41. if err <> 0 then
  42. scriptHelper.writeErrorToLog err, "Failed to set class name"
  43. else
  44. scriptHelper.writeToLog "Successful set of class name", 2
  45. end if
  46. ' Add a non-array property (uint32)
  47. set p0 = newClass.Properties_.Add ("p0", wbemCimtypeUint32)
  48. p0.Value = 251
  49. ' Add an array property
  50. set p1 = newClass.Properties_.Add ("p1", wbemCimtypeUint32, true)
  51. p1.Value = Array (1, 2, 3)
  52. ' Try getting a non array value as an array
  53. v = p0.ArrayValue
  54. scriptHelper.DisplayValue newClass, "p0"
  55. scriptHelper.VerifyValue v, Array(251)
  56. ' Try getting an array value as an array
  57. v = p1.ArrayValue
  58. scriptHelper.DisplayValue newClass, "p1"
  59. scriptHelper.VerifyValue v, Array (1, 2, 3)
  60. ' Try a null value
  61. p0.Value = null
  62. scriptHelper.DisplayValue newClass, "p0"
  63. scriptHelper.VerifyValue p0.ArrayValue, null
  64. scriptHelper.testComplete
  65. if scriptHelper.statusOK then
  66. WScript.Echo "PASS"
  67. WScript.Quit 0
  68. else
  69. WScript.Echo "FAIL"
  70. WScript.Quit 1
  71. end if
  72. </script>
  73. </job>