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.

54 lines
1.2 KiB

  1. var context = WScript.CreateObject ("WbemScripting.SWbemNamedValueSet");
  2. context.Add ("J", null);
  3. context.Add ("fred", 23);
  4. context("fred").Value = 12;
  5. context.Add ("Hah", true);
  6. context.Add ("Whoah", "Freddy the frog");
  7. // A string array
  8. var bam = new Array ("whoops", "a", "daisy");
  9. context.Add ("Bam", bam);
  10. // An embedded object
  11. WScript.Echo ("There are", context.Count , "elements in the context");
  12. context.Remove("hah");
  13. WScript.Echo ("There are", context.Count , "elements in the context");
  14. context.Remove("Hah");
  15. WScript.Echo ("There are", context.Count , "elements in the context");
  16. var bam = new VBArray (context("Bam").Value).toArray ();
  17. WScript.Echo ("");
  18. WScript.Echo ("Here are the names:");
  19. WScript.Echo ("==================");
  20. for (var x = 0; x < bam.length; x++) {
  21. WScript.Echo (bam[x]);
  22. }
  23. WScript.Echo ("");
  24. WScript.Echo ("Here are the names & values:");
  25. WScript.Echo ("===========================");
  26. // Use the Enumerator helper to manipulate collections
  27. e = new Enumerator (context);
  28. s = "";
  29. for (;!e.atEnd();e.moveNext ())
  30. {
  31. var y = e.item ();
  32. s += y.Name;
  33. s += "=";
  34. if (null != y.Value)
  35. s += y;
  36. s += "\n";
  37. }
  38. WScript.Echo (s);