Export Registry Value

  • Thread starter Thread starter Barry Petzold
  • Start date Start date
B

Barry Petzold

Is there a way to export a single registry value?

Using the reg command, I can do a "reg export", but that exports every
value in a specific key. I need to export a single value and cant seem
to figure out how!

Thanks!
 
Barry said:
Is there a way to export a single registry value?

Using the reg command, I can do a "reg export", but that
exports every value in a specific key. I need to export
a single value and cant seem to figure out how!
Hi,

A couple of batch file examples below.

The first one just dumps the registry value data to a text file.
The second one builds a reg file and displays it in Notepad.

Some notes:

Batch files below will not work correctly if there is one or more space
in the registry value data.

If there is one or more space in the registry value name, you will need
to add to the number behind Tokens= as there is spaces.

The last batch file is creating a registry file based on that the
registry value is of type REG_SZ. If it is of another type, you will
need to modify what the echo commands do.


Just dumping the registry value data to a text file:
--------------------8<----------------------
@echo off
setlocal
set rkey=HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion
set rvalue="RegisteredOwner"
set regexe=%SystemRoot%\System32\Reg.exe
for /f "Skip=4 Tokens=3" %%a in ('%regexe% QUERY "%rkey%" /v %rvalue%') do (
set rdata=%%a
)

echo %rdata% >c:\tst.txt
start notepad.exe c:\tst.txt
endlocal
--------------------8<----------------------



Building a reg file and display it in Notepad:
--------------------8<----------------------
@echo off
setlocal
set rkey=HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion
set rvalue="RegisteredOwner"
set regexe=%SystemRoot%\System32\Reg.exe
for /f "Skip=4 Tokens=3" %%a in ('%regexe% QUERY "%rkey%" /v %rvalue%') do (
set rdata=%%a
)

set regfile="c:\my tst.reg"

echo REGEDIT4>%regfile%
echo.>>%regfile%
echo [%rkey%]>>%regfile%
echo %rvalue%^="%rdata%">>%regfile%
echo.>>%regfile%

start notepad.exe %regfile%

endlocal
--------------------8<----------------------
 
I do not know if this is what you are looking for, but here is one way.

From within the regedit program -

In the left pane, right click on the registry value that you would like to
export and select export.

Give it any name, usually the registry key name works for me.

Hope this helps
Michael Wayne
 
Back
Top