根据搜索字符串从REG QUERY中提取特定注册表项

时间:2015-06-04 15:03:39

标签: windows for-loop cmd registry

我正在尝试提取注册表项的键值。我只想要使用 <div class=""> <h1 id="multiple-axis" class="title">Multiple Axis</h1> <p class="description">Different types of data can be visualized in a single chart with the help of</p> <p class="description">It can be used when we need to compare the trends of different kinds of data.</p> </div> 尝试连接的密钥,但是没有运气。

例如:命令

FOR /F

返回

REG QUERY HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall /s /f chrome

我希望从此结果获得的所有内容都是 HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{157F97DF-A001-36FB-A90C-55949FA130CA} DisplayName REG_SZ Google Chrome End of search: 1 match(es) found.

如何使用 157F97DF-A001-36FB-A90C-55949FA130CA 或其他类似方法执行此操作?

非常感谢!!

1 个答案:

答案 0 :(得分:2)

您可以尝试使用{}分隔线作为分隔符

@echo off
    setlocal enableextensions disabledelayedexpansion

    for /f "tokens=2 delims={}" %%a in ('
        REG QUERY HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall /s /f chrome
    ') do set "value=%%a"

    echo %value%