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.7 KiB

  1. on error resume next
  2. Set Service = GetObject("winmgmts:root/default")
  3. 'Create a simple embeddable object
  4. Set aClass = Service.Get
  5. aClass.Path_.Class = "INNEROBJ01"
  6. Set Property = aClass.Properties_.Add ("p", 19)
  7. aClass.Properties_.Add ("q", 8).Value = "resnais"
  8. Property.Qualifiers_.Add "fred", "wibbley"
  9. Property.Qualifiers_.Add "dibnah", "wobbley"
  10. aClass.Qualifiers_.Add "stavisky", "providence"
  11. aClass.Qualifiers_.Add "muriel", "brouillard"
  12. aClass.Put_
  13. Set aClass = Service.Get ("INNEROBJ01")
  14. aClass.p = 8778
  15. 'Create a class that uses that object
  16. Set Class2 = Service.Get
  17. Class2.Path_.Class = "EMBOBJTEST01"
  18. Class2.Properties_.Add ("p1", 13).Value = aClass
  19. 'Now modify the path
  20. aClass.Path_.Class = "LAGUERRE"
  21. WScript.Echo "The current value of EMBOBJTEST01.p1.Path_.Class is [LAGUERRE]:", Class2.p1.Path_.Class
  22. WScript.Echo
  23. 'Modify the qualifier set of the class
  24. aClass.Qualifiers_.Remove "muriel"
  25. aClass.Qualifiers_.Add "fumer", "pasdefumer"
  26. Set Qualifier = aClass.Qualifiers_("stavisky")
  27. Qualifier.Value = "melo"
  28. Wscript.Echo "Qualifiers of EMBOBJTEST01.p1 are [(fumer,pasdefumer),(stavisky,melo)]:"
  29. for each Qualifier in Class2.p1.Qualifiers_
  30. WScript.Echo Qualifier.Name, Qualifier.Value
  31. next
  32. Wscript.Echo "Qualifier [stavisky] has flavor [-1,-1,-1]:", Class2.p1.Qualifiers_("stavisky").IsOverridable, _
  33. Class2.p1.Qualifiers_("stavisky").PropagatesToInstance, _
  34. Class2.p1.Qualifiers_("stavisky").PropagatesToSubclass
  35. Set Qualifier = aClass.Qualifiers_("stavisky")
  36. Qualifier.IsOverridable = false
  37. Qualifier.PropagatesToInstance = false
  38. Qualifier.PropagatesToSubclass = false
  39. Wscript.Echo "Qualifier [stavisky] has flavor [0,0,0]:", Class2.p1.Qualifiers_("stavisky").IsOverridable, _
  40. Class2.p1.Qualifiers_("stavisky").PropagatesToInstance, _
  41. Class2.p1.Qualifiers_("stavisky").PropagatesToSubclass
  42. 'Modify the qualifier set of the property
  43. aClass.Properties_("p").Qualifiers_.Remove "fred"
  44. aClass.Properties_("p").Qualifiers_.Add "steeple", "jack"
  45. aClass.Properties_("p").Qualifiers_("dibnah").Value = "demolition"
  46. WScript.Echo
  47. Wscript.Echo "Qualifiers of EMBOBJTEST01.p1.p are [(steeple,jack),(dibnah,demolition)]:"
  48. for each Qualifier in Class2.p1.Properties_("p").Qualifiers_
  49. WScript.Echo Qualifier.Name, Qualifier.Value
  50. next
  51. 'Modify the property set of the property
  52. aClass.Properties_.Remove "q"
  53. aClass.Properties_.Add ("r", 19).Value = 27
  54. aClass.Properties_("p").Value = 99
  55. WScript.Echo
  56. Wscript.Echo "Properties of EMBOBJTEST01.p1 are [(p,99),(r,27)]:"
  57. for each Property in Class2.p1.Properties_
  58. WScript.Echo Property.Name, Property.Value
  59. next
  60. Class2.Put_
  61. if Err <> 0 Then
  62. WScript.Echo Err.Description, Err.Source
  63. Err.Clear
  64. End if