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.

62 lines
2.6 KiB

  1. //***************************************************************************
  2. //This script tests the inspection of empty arrays on properties, qualifiers
  3. //and value sets
  4. //***************************************************************************
  5. var Service = GetObject("winmgmts:root/default");
  6. var MyClass = Service.Get();
  7. MyClass.Path_.Class = "EMPTYARRAYTEST00";
  8. //*************************
  9. //CASE 1: Property values
  10. //*************************
  11. var Property = MyClass.Properties_.Add ("p1", 2, true);
  12. Property.Value = new Array ();
  13. var arrayValue = new VBArray (MyClass.Properties_("p1").Value).toArray ();
  14. WScript.Echo ("Array length for property value is [0]:", arrayValue.length);
  15. WScript.Echo ("Base CIM property type is [2]", Property.CIMType);
  16. WScript.Echo ();
  17. //*************************
  18. //CASE 2: Qualifier values
  19. //*************************
  20. MyClass.Qualifiers_.Add ("q1", Array);
  21. arrayValue = new VBArray (MyClass.Qualifiers_("q1").Value).toArray ();
  22. WScript.Echo ("Array length for qualifier value is [0]:", arrayValue.length);
  23. WScript.Echo ();
  24. MyClass.Put_();
  25. //Now read them back and assign "real values"
  26. var MyClass = Service.Get("EMPTYARRAYTEST00");
  27. MyClass.Properties_("p1").Value = new Array (12, 34, 56);
  28. arrayValue = new VBArray (MyClass.Properties_("p1").Value).toArray ();
  29. WScript.Echo ("Array length for property value is [3]:", arrayValue.length);
  30. WScript.Echo ("Base CIM property type is [2]", Property.CIMType);
  31. WScript.Echo ();
  32. MyClass.Properties_("p1").Value = new Array ();
  33. var arrayValue = new VBArray (MyClass.Properties_("p1").Value).toArray ();
  34. WScript.Echo ("Array length for property value is [0]:", arrayValue.length);
  35. WScript.Echo ("Base CIM property type is [2]", Property.CIMType);
  36. WScript.Echo ();
  37. MyClass.Qualifiers_("q1").Value = new Array ("Hello", "World");
  38. arrayValue = new VBArray (MyClass.Qualifiers_("q1").Value).toArray ();
  39. WScript.Echo ("Array length for qualifier value is [2]:", arrayValue.length);
  40. WScript.Echo ();
  41. MyClass.Qualifiers_("q1").Value = new Array ();
  42. arrayValue = new VBArray (MyClass.Qualifiers_("q1").Value).toArray ();
  43. WScript.Echo ("Array length for qualifier value is [0]:", arrayValue.length);
  44. WScript.Echo ();
  45. MyClass.Put_ ();
  46. //*************************
  47. //CASE 3:Named Values
  48. //*************************
  49. var NValueSet = new ActiveXObject("WbemScripting.SWbemNamedValueSet");
  50. var NValue = NValueSet.Add ("Foo", new Array ());
  51. var arrayValue = new VBArray (NValueSet("Foo").Value).toArray ();
  52. WScript.Echo ("Array length for named value is [0]:", arrayValue.length);