标题: [注册表类] 如何获取注册表指定主键下面的子项和键值 [打印本页]
作者: freesoft00 时间: 2017-4-7 14:10 标题: 如何获取注册表指定主键下面的子项和键值
本帖最后由 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
下面是示例注册表内容:- Windows Registry Editor Version 5.00
-
- [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\x86_wpf-windowsformsintegration_31bf3856ad364e35_none_4d389f9297507f37\6.1]
- @="6.1.7600.16385"
-
- [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\SideBySide\Winners\x86_wpf-winfxlist_31bf3856ad364e35_none_e6d5f2026df4d42f\6.1]
- @="6.1.7600.16385"
-
- [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\SideBySide\Winners\x86_wpf-winfxtargets_31bf3856ad364e35_none_5808d886af87421d\6.1]
- @="6.1.7600.16385"
-
- [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\SideBySide\Winners\x86_wpf-xamlviewerapplicationmanifest_31bf3856ad364e35_none_e009ddfae332ac32]
- @="6.1"
-
- [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\SideBySide\Winners\x86_wpf-xamlviewerapplicationmanifest_31bf3856ad364e35_none_e009ddfae332ac32\6.1]
- @="6.1.7601.17514"
- "6.1.7601.17514"=hex:01
-
- [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\SideBySide\Winners\x86_wpf-xamlviewerdeploymentmanifest_31bf3856ad364e35_none_38b7246271b2a70d]
- @="6.1"
-
- [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\SideBySide\Winners\x86_wpf-xamlviewerdeploymentmanifest_31bf3856ad364e35_none_38b7246271b2a70d\6.1]
- @="6.1.7601.17514"
- "6.1.7601.17514"=hex:01
-
- [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\SideBySide\Winners\x86_wpf-xamlviewer_31bf3856ad364e35_none_462351402569bd53]
- @="6.1"
-
- [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\SideBySide\Winners\x86_wpf-xamlviewer_31bf3856ad364e35_none_462351402569bd53\6.1]
- @="6.1.7600.16385"
-
- [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\SideBySide\Winners\x86_wsdapi.resources_31bf3856ad364e35_zh-cn_b1df5e8b9c90e874\6.1]
- @="6.1.7600.16385"
-
- [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\SideBySide\Winners\x86_wwf-cperfcnt_31bf3856ad364e35_none_429ddb3ffa5892df\6.1]
- @="6.1.7600.16385"
-
- [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\SideBySide\Winners\x86_wwf-cwetargets_i_31bf3856ad364e35_none_322187b870886fb1\6.1]
- @="6.1.7600.16385"
-
- [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\SideBySide\Winners\x86_wwf-cwevbtargets_i_31bf3856ad364e35_none_98c294b7d1096475\6.1]
- @="6.1.7600.16385"
-
- [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\SideBySide\Winners\x86_wwf-netfx3reg_31bf3856ad364e35_none_b3e33e0b5e16fb18\6.1]
- @="6.1.7601.17514"
-
- [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\SideBySide\Winners\x86_wwf-ngenpriorities_31bf3856ad364e35_none_335afdde804253ce\6.1]
- @="6.1.7600.16385"
-
- [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\SideBySide\Winners\x86_wwf-perfcnt_ini_31bf3856ad364e35_none_e40fc3b0faeccca3\6.1]
- @="6.1.7600.16385"
-
- [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\SideBySide\Winners\x86_wwf-servicing_key_productfamily_31bf3856ad364e35_none_6c0815dc1d6e080e\6.1]
- @="6.1.7600.16385"
-
- [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\SideBySide\Winners\x86_wwf-servicing_key_product_31bf3856ad364e35_none_c7302f96a237876e\6.1]
- @="6.1.7600.16385"
-
- [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\SideBySide\Winners\x86_wwf-system.workflow.activities_31bf3856ad364e35_none_3a6b4fe15ed98a59\6.1]
- @="6.1.7601.17514"
-
- [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\SideBySide\Winners\x86_wwf-system.workflow.componentmodel_31bf3856ad364e35_none_55db25c7870fe030\6.1]
- @="6.1.7601.17514"
-
- [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\SideBySide\Winners\x86_wwf-system.workflow.runtime_31bf3856ad364e35_none_a8bc241be89fbabc\6.1]
- @="6.1.7601.17514"
-
- [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\SideBySide\Winners\x86_netfx-_vc_assembly_linker_dll_b03f5f7f11d50a3a_none_89e404dea6a2a44c\6.1]
- @="6.1.7601.18523"
-
- [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\SideBySide\Winners\amd64_.netframework_31bf3856ad364e35_none_f5dd4e94975c8e4e\6.1]
- @="6.1.7600.16385"
-
- [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_accessibility_b03f5f7f11d50a3a_none_a3102863224179f3\6.1]
- @="6.1.7601.18523"
-
- [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\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"
复制代码
作者: WHY 时间: 2017-4-8 17:14
本帖最后由 WHY 于 2017-4-9 15:37 编辑
不知道是不是这个意思,试试吧- @if(0)==(0) echo off
- set "key=HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\SideBySide\Winners"
- reg query "%key%" /s /ve | cscript //nologo //e:jscript "%~f0" > Result.Log
- pause & goto :EOF
- @end
-
- var str = WSH.StdIn.ReadAll();
- var reg = /HKEY_.+\\([^\\]+_[0-9a-f]{16}_)([^\\]+)\\([0-9.]+)\r\n.+REG_SZ\s+([0-9.]+)/g;
- var map = [], arr = [];
-
- while(arr = reg.exec(str)){
- var s1 = arr[1] + arr[2];
- if(!map[s1]) map[s1] = [[],[]];
- map[s1][0].push(arr[1] + arr[3]);
- map[s1][1].push(arr[1] + arr[4]);
- }
-
- for(var key in map){
- var len = map[key][0].length;
- WSH.Echo( len > 1 ? map[key][1].join('\r\n') : map[key][0] )
- }
复制代码
欢迎光临 批处理之家 (http://www.bathome.net/) |
Powered by Discuz! 7.2 |