[新手上路]批处理新手入门导读[视频教程]批处理基础视频教程[视频教程]VBS基础视频教程[批处理精品]批处理版照片整理器
[批处理精品]纯批处理备份&还原驱动[批处理精品]CMD命令50条不能说的秘密[在线下载]第三方命令行工具[在线帮助]VBScript / JScript 在线参考
返回列表 发帖

[注册表类] 如何获取注册表指定主键下面的子项和键值

本帖最后由 pcl_test 于 2017-4-7 17:44 编辑

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\SideBySide\Winners路径下面的注册表文件,内容大致类似下面:
例如
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\SideBySide\Winners\x86_wpf-windowsbase_31bf3856ad364e35_none_01c469c6f26e0be3\6.1]
@="6.1.7601.23614"

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\SideBySide\Winners\amd64_001f7a5d0424f0c7d3819a79c828c6d4_31bf3856ad364e35_none_ccc692e52cdb7ed7\11.2]
@="11.2.9600.17914"

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\SideBySide\Winners\msil_aspnet_regbrowsers.resources_b03f5f7f11d50a3a_zh-cn_3e41287196e5cdc1\6.1]
@="6.1.7601.18410"

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\SideBySide\Winners\x86_netfx-_vc_assembly_linker_dll_b03f5f7f11d50a3a_none_89e404dea6a2a44c\6.1]
@="6.1.7601.18523"
需要获取的是红色部分的注册表内容,是否可以有办法。我要截取的Winners下面第一级子项的命名规律应该是截取的文件结尾都是“_16个字母和数字组合_“,例如x86_netfx-_vc_assembly_linker_dll_b03f5f7f11d50a3a_   msil_aspnet_regbrowsers.resources_b03f5f7f11d50a3a_
因为HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\SideBySide\Winners下面的注册表项很多。所以获取的内容可以设定为str1 str2 str3的变量,都重定向到一个文本文件就可以。

上面的举例一般是子项下面有一个子项,如果是只有一个二级子项比如6.1或11.2等就这个str2就设定为00

而下面这个amd64_microsoft.windows.common-controls_6595b64144ccf1df_none_62fe57338acfab7a下面有两个子项,分别是5.82和6.0,那么str2就取其值即可。
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\SideBySide\Winners\amd64_microsoft.windows.common-controls_6595b64144ccf1df_none_62fe57338acfab7a\5.82]
@="5.82.7601.18837"

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\SideBySide\Winners\amd64_microsoft.windows.common-controls_6595b64144ccf1df_none_62fe57338acfab7a\6.0]
@="6.0.7601.18837"


生成的2个txt文本类似下面这样:
str1+str3的组合
amd64_microsoft.windows.common-controls_6595b64144ccf1df_6.0.7601.18837
amd64_microsoft.windows.common-controls_6595b64144ccf1df_5.82.7601.18837
x86_wpf-windowsbase_31bf3856ad364e35_6.1.7601.23614
amd64_001f7a5d0424f0c7d3819a79c828c6d4_31bf3856ad364e35_11.2.9600.17914

str1+str2的组合
amd64_microsoft.windows.common-controls_5.82
amd64_microsoft.windows.common-controls_6.0
x86_wpf-windowsbase_31bf3856ad364e35_0.0
amd64_001f7a5d0424f0c7d3819a79c828c6d4_31bf3856ad364e35_0.0




下面是示例注册表内容:
  1. Windows Registry Editor Version 5.00
  2. [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\SideBySide\Winners\x86_wpf-windowsbase_31bf3856ad364e35_none_01c469c6f26e0be3\6.1]
  3. @="6.1.7601.23614"
  4. [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\SideBySide\Winners\x86_wpf-windowsformsintegration_31bf3856ad364e35_none_4d389f9297507f37\6.1]
  5. @="6.1.7600.16385"
  6. [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\SideBySide\Winners\x86_wpf-winfxlist_31bf3856ad364e35_none_e6d5f2026df4d42f\6.1]
  7. @="6.1.7600.16385"
  8. [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\SideBySide\Winners\x86_wpf-winfxtargets_31bf3856ad364e35_none_5808d886af87421d\6.1]
  9. @="6.1.7600.16385"
  10. [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\SideBySide\Winners\x86_wpf-xamlviewerapplicationmanifest_31bf3856ad364e35_none_e009ddfae332ac32]
  11. @="6.1"
  12. [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\SideBySide\Winners\x86_wpf-xamlviewerapplicationmanifest_31bf3856ad364e35_none_e009ddfae332ac32\6.1]
  13. @="6.1.7601.17514"
  14. "6.1.7601.17514"=hex:01
  15. [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\SideBySide\Winners\x86_wpf-xamlviewerdeploymentmanifest_31bf3856ad364e35_none_38b7246271b2a70d]
  16. @="6.1"
  17. [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\SideBySide\Winners\x86_wpf-xamlviewerdeploymentmanifest_31bf3856ad364e35_none_38b7246271b2a70d\6.1]
  18. @="6.1.7601.17514"
  19. "6.1.7601.17514"=hex:01
  20. [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\SideBySide\Winners\x86_wpf-xamlviewer_31bf3856ad364e35_none_462351402569bd53]
  21. @="6.1"
  22. [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\SideBySide\Winners\x86_wpf-xamlviewer_31bf3856ad364e35_none_462351402569bd53\6.1]
  23. @="6.1.7600.16385"
  24. [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\SideBySide\Winners\x86_wsdapi.resources_31bf3856ad364e35_zh-cn_b1df5e8b9c90e874\6.1]
  25. @="6.1.7600.16385"
  26. [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\SideBySide\Winners\x86_wwf-cperfcnt_31bf3856ad364e35_none_429ddb3ffa5892df\6.1]
  27. @="6.1.7600.16385"
  28. [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\SideBySide\Winners\x86_wwf-cwetargets_i_31bf3856ad364e35_none_322187b870886fb1\6.1]
  29. @="6.1.7600.16385"
  30. [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\SideBySide\Winners\x86_wwf-cwevbtargets_i_31bf3856ad364e35_none_98c294b7d1096475\6.1]
  31. @="6.1.7600.16385"
  32. [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\SideBySide\Winners\x86_wwf-netfx3reg_31bf3856ad364e35_none_b3e33e0b5e16fb18\6.1]
  33. @="6.1.7601.17514"
  34. [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\SideBySide\Winners\x86_wwf-ngenpriorities_31bf3856ad364e35_none_335afdde804253ce\6.1]
  35. @="6.1.7600.16385"
  36. [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\SideBySide\Winners\x86_wwf-perfcnt_ini_31bf3856ad364e35_none_e40fc3b0faeccca3\6.1]
  37. @="6.1.7600.16385"
  38. [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\SideBySide\Winners\x86_wwf-servicing_key_productfamily_31bf3856ad364e35_none_6c0815dc1d6e080e\6.1]
  39. @="6.1.7600.16385"
  40. [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\SideBySide\Winners\x86_wwf-servicing_key_product_31bf3856ad364e35_none_c7302f96a237876e\6.1]
  41. @="6.1.7600.16385"
  42. [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\SideBySide\Winners\x86_wwf-system.workflow.activities_31bf3856ad364e35_none_3a6b4fe15ed98a59\6.1]
  43. @="6.1.7601.17514"
  44. [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\SideBySide\Winners\x86_wwf-system.workflow.componentmodel_31bf3856ad364e35_none_55db25c7870fe030\6.1]
  45. @="6.1.7601.17514"
  46. [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\SideBySide\Winners\x86_wwf-system.workflow.runtime_31bf3856ad364e35_none_a8bc241be89fbabc\6.1]
  47. @="6.1.7601.17514"
  48. [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\SideBySide\Winners\x86_netfx-_vc_assembly_linker_dll_b03f5f7f11d50a3a_none_89e404dea6a2a44c\6.1]
  49. @="6.1.7601.18523"
  50. [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\SideBySide\Winners\amd64_.netframework_31bf3856ad364e35_none_f5dd4e94975c8e4e\6.1]
  51. @="6.1.7600.16385"
  52. [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\SideBySide\Winners\amd64_001f7a5d0424f0c7d3819a79c828c6d4_31bf3856ad364e35_none_ccc692e52cdb7ed7\11.2]
  53. @="11.2.9600.17914"
  54. [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\SideBySide\Winners\msil_accessibility_b03f5f7f11d50a3a_none_a3102863224179f3\6.1]
  55. @="6.1.7601.18523"
  56. [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\SideBySide\Winners\msil_aspnet_regbrowsers.resources_b03f5f7f11d50a3a_zh-cn_3e41287196e5cdc1\6.1]
  57. @="6.1.7601.18410"
  58. [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\SideBySide\Winners\amd64_microsoft.windows.common-controls_6595b64144ccf1df_none_62fe57338acfab7a\5.82]
  59. @="5.82.7601.18837"
  60. [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\SideBySide\Winners\amd64_microsoft.windows.common-controls_6595b64144ccf1df_none_62fe57338acfab7a\6.0]
  61. @="6.0.7601.18837"
复制代码

本帖最后由 WHY 于 2017-4-9 15:37 编辑

不知道是不是这个意思,试试吧
  1. @if(0)==(0) echo off
  2. set "key=HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\SideBySide\Winners"
  3. reg query "%key%" /s /ve | cscript //nologo //e:jscript "%~f0" > Result.Log
  4. pause & goto :EOF
  5. @end
  6. var str = WSH.StdIn.ReadAll();
  7. var reg = /HKEY_.+\\([^\\]+_[0-9a-f]{16}_)([^\\]+)\\([0-9.]+)\r\n.+REG_SZ\s+([0-9.]+)/g;
  8. var map = [], arr = [];
  9. while(arr = reg.exec(str)){
  10.     var s1 = arr[1] + arr[2];
  11.     if(!map[s1]) map[s1] = [[],[]];
  12.     map[s1][0].push(arr[1] + arr[3]);
  13.     map[s1][1].push(arr[1] + arr[4]);
  14. }
  15. for(var key in map){
  16.     var len = map[key][0].length;
  17.     WSH.Echo( len > 1 ? map[key][1].join('\r\n') : map[key][0] )
  18. }
复制代码
1

评分人数

TOP

返回列表