15

我有以下查询 -

@ECHO OFF
REG QUERY "HKEY_CURRENT_USER\Software\Microsoft\Microsoft Games\Flight Simulator\10.0" /v AppPath
PAUSE

这将返回条目的名称、类型和数据,如下所示 -

HKEY_CURRENT_USER\Software\Microsoft\Microsoft Games\Flight Simulator\10.0
    AppPath    REG_SZ    C:\Program Files (x86)\Microsoft Games\Microsoft Flight Simulator X\

Press any key to continue . . .

是否可以只检索注册表项的数据部分?

4

3 回答 3

31
for /f "tokens=2*" %%a in ('REG QUERY "HKEY_CURRENT_USER\Software\Microsoft\Microsoft Games\Flight Simulator\10.0" /v AppPath') do set "AppPath=%%~b"
echo %AppPath%
pause
于 2013-10-25T04:46:02.893 回答
1

波纹管命令确实有效,例如我想获取操作系统名称:

for /f "tokens=2*" %%a in ('reg query "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion" /v ProductName ^| findstr "REG_"') do @echo %%b

输出是:

Windows 10 Enterprise
于 2018-10-15T07:42:59.417 回答
-2

感谢您的回答,这里添加了一个能够将字符串附加到值的附加功能:

for /f "tokens=2*" %%a in ('REG QUERY "HKEY_LOCAL_MACHINE\SOFTWARE\...." /v keyname') do set "AppPath=%%~b"
reg add "HKEY_LOCAL_MACHINE\SOFTWARE\..." /v "keyname" /f /t REG_SZ /d "%AppPath% appended value"
于 2014-11-03T13:42:20.873 回答