wsRegReadListStream.wsf 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. '
  2. ' Lists the values of a given registry path, this script takes its input from stdin
  3. '
  4. ' echo HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\User Shell Folders\\AppData | cscript regListStream.wsf A
  5. '
  6. ' Will Yield:
  7. '
  8. ' {
  9. ' "HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\User Shell Folders\\AppData": "value here"
  10. ' }
  11. <job id="regRead">
  12. <script language="VBScript" src="util.vbs" />
  13. <script language="VBScript" src="regUtil.vbs" />
  14. <script language="VBScript">
  15. CheckZeroArgs("usage: echo KEY | cscript wsRegRead.wsf architecture")
  16. DetermineOSArchitecture()
  17. LoadRegistryImplementationByOSArchitecture()
  18. set ws = createobject("Wscript.shell")
  19. Do While Not stdin.AtEndOfLine
  20. strLine = stdin.ReadLine()
  21. strLine = unescape(trim(strLine))
  22. ' not really needed except for validation
  23. ParseHiveAndSubKeyAndValue strLine, constHive, strSubKey, strValue
  24. if IsNull(constHive) Then
  25. WriteLineErr "unsupported hive " & strLine
  26. WScript.Quit 25122
  27. End If
  28. Write "{ ""path"" : """ & JsonSafe(strLine) & """, "
  29. Dim result: result = ws.RegRead(strLine)
  30. Dim exists: exists = "true"
  31. If Err.Number <> 0 Then
  32. exists = "false"
  33. End if
  34. Write """exists"": " & exists & ", "
  35. Write """value"": """ & JsonSafe(result) & """}" & vbcrlf
  36. Loop
  37. </script>
  38. </job>