wsRegReadList.wsf 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. '
  2. ' Lists the values of a given registry path, this script takes its input from stdin
  3. '
  4. ' cscript regListStream.wsf A "HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\User Shell Folders\\AppData"
  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: cscript wsRegRead.wsf architecture path1...pathN")
  16. DetermineOSArchitecture()
  17. LoadRegistryImplementationByOSArchitecture()
  18. set ws = createobject("Wscript.shell")
  19. Write "["
  20. On Error Resume Next
  21. For v = 1 To args.Count - 1
  22. If (v > 1) Then
  23. Write ","
  24. End If
  25. Dim key: key = trim(args(v))
  26. ' not really needed except for validation
  27. ParseHiveAndSubKeyAndValue key, constHive, strSubKey, strValue
  28. if IsNull(constHive) Then
  29. WriteLineErr "unsupported hive " & args(v)
  30. WScript.Quit 25122
  31. End If
  32. Write "{ ""path"" : """ & JsonSafe(key) & """, "
  33. Dim result: result = ws.RegRead(args(v))
  34. Dim exists: exists = "true"
  35. If Err.Number <> 0 Then
  36. exists = "false"
  37. End if
  38. Write """exists"": " & exists & ", "
  39. Write """value"": """ & JsonSafe(result) & """}" & vbcrlf
  40. Next
  41. Write "]"
  42. </script>
  43. </job>