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.

84 lines
1.8 KiB

  1. WScript.Echo ("");
  2. WScript.Echo ("Create an Object Path");
  3. WScript.Echo ("");
  4. var d = new ActiveXObject("WbemScripting.SWbemObjectPath");
  5. d.Path = '\\erewhon\ROOT\DEFAULT:Foo.Bar=12,Wibble="Hah"';
  6. DumpPath(d);
  7. d.RelPath = "Hmm.G=1,H=3";
  8. WScript.Echo ();
  9. DumpPath(d);
  10. WScript.Echo ();
  11. WScript.Echo ("Extract an Object Path from a class");
  12. WScript.Echo ();
  13. var c = GetObject("winmgmts:").Get();
  14. c.Path_.Class = "PATHTEST00";
  15. var p = c.Put_();
  16. DumpPath(p);
  17. WScript.Echo ();
  18. WScript.Echo ("Extract an Object Path from a singleton");
  19. WScript.Echo ();
  20. var i = GetObject("winmgmts:root/default:__cimomidentification=@");
  21. var p = i.Path_;
  22. DumpPath(p);
  23. WScript.Echo ();
  24. WScript.Echo ("Extract an Object Path from a keyed instance");
  25. WScript.Echo ();
  26. var i = GetObject('winmgmts:{impersonationLevel=Impersonate}!win32_logicaldisk="C:"');
  27. var p = i.Path_;
  28. DumpPath(p);
  29. WScript.Echo ();
  30. WScript.Echo ("Clone keys");
  31. WScript.Echo ();
  32. var newKeys = p.Keys.Clone();
  33. DumpKeys (newKeys);
  34. WScript.Echo ();
  35. WScript.Echo ("Change Cloned keys");
  36. WScript.Echo ();
  37. //Note that the cloned copy of Keys _should_ be mutable
  38. newKeys.Add ("fred", 23);
  39. newKeys.Remove ("DeviceID");
  40. DumpKeys (newKeys);
  41. function DumpPath(p)
  42. {
  43. WScript.Echo ("Path=", p.Path);
  44. WScript.Echo ("RelPath=",p.RelPath);
  45. WScript.Echo ("Class=", p.Class);
  46. WScript.Echo ("Server=", p.Server);
  47. WScript.Echo ("Namespace=", p.Namespace);
  48. WScript.Echo ("DisplayName=", p.DisplayName);
  49. WScript.Echo ("ParentNamespace=", p.ParentNamespace);
  50. WScript.Echo ("IsClass=", p.IsClass);
  51. WScript.Echo ("IsSingleton=", p.IsSingleton);
  52. DumpKeys (p.Keys);
  53. }
  54. function DumpKeys (keys)
  55. {
  56. var e = new Enumerator (keys);
  57. for (;!e.atEnd();e.moveNext ())
  58. {
  59. var key = e.item ();
  60. WScript.Echo ("KeyName:", key.Name, "KeyValue:", key.Value );
  61. }
  62. }