regListStream.wsf 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. '
  2. ' Lists the sub keys and values of a given registry key, this script is slightly different
  3. ' than regList because it reads stdin for the keys to list
  4. '
  5. ' echo HKLM\Software | cscript regListStream.wsf A
  6. '
  7. ' Will Yield:
  8. '
  9. ' {
  10. ' "hklm\software": {
  11. ' "keys": [ .. array of sub keys .. ],
  12. ' "values": {
  13. ' "moo": {
  14. ' "type": "REG_SZ",
  15. ' "value": "bar"
  16. ' }
  17. ' }
  18. ' }
  19. ' }
  20. <job id="listStream">
  21. <script language="VBScript" src="util.vbs" />
  22. <script language="VBScript" src="regUtil.vbs" />
  23. <script language="VBScript">
  24. CheckZeroArgs("usage: echo KEY | cscript regListStream.wsf architecture")
  25. DetermineOSArchitecture()
  26. LoadRegistryImplementationByOSArchitecture()
  27. Do While Not stdin.AtEndOfLine
  28. strLine = stdin.ReadLine()
  29. strLine = unescape(trim(strLine))
  30. ParseHiveAndSubKey strLine, constHive, strSubKey
  31. if IsNull(constHive) Then
  32. WriteLineErr "unsupported hive " & strLine
  33. WScript.Quit 25122
  34. End If
  35. Write "{ ""key"" : """ & JsonSafe(strLine) & """, ""data"": "
  36. ListChildrenAsJson constHive, strSubKey
  37. Write "}" & vbcrlf
  38. Loop
  39. </script>
  40. </job>