简体   繁体   中英

How to read (Default) value from registry and put into a variable within a batch file?

I know there are a lot of questions with reading values from registry, set to a variable in a bat file, but i did not figure out how the read the (default) value??
If I use

Reg.exe QUERY "HKLM\\SOFTWARE\\Wow6432Node\\Notepad++"


I will get

(Default) REG_SZ C:\\ProgramFiles (x86)\\Notepad++

but if I use the code:

@echo OFF
Reg.exe QUERY "HKLM\\SOFTWARE\\Wow6432Node\\Notepad++"
setlocal ENABLEEXTENSIONS
FOR /F "usebackq skip=2 tokens=1-3" %%A IN ('Reg QUERY "HKLM\\SOFTWARE\\Wow6432Node\\Notepad++" ') DO (
set ValueType=%%B
set ValueValue=%%C
)
if defined ValueType(
@echo Value Type = %ValueType%
@echo Value Value = %ValueValue%
) else (
@echo not found.
)

I get the error: "The syntax of the command is incorrect"
What I want is to put into ValueValue = C:\\ProgramFiles (x86)\\Notepad++
Someone can help me?

From the cmd line:

for /f "tokens=3*" %a in ('reg query "HKLM\SOFTWARE\Wow6432Node\Notepad++"') do echo %a %b

if you want to do it in script, double the %'s

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM