I have windows 7 ultimate 32 bit and and I need a batch script that can backup the registry to a .reg file call "Registry backup" in the same directory as the batch file can any one help me find a code to do this.
Exporting the whole registry to a single .reg file is not so easy, but you can use the Reg.exe
utility that is installed with Windows to export a chosen root key.
Documentation for Reg.exe
can be found here.
For example, to save each of the valid root keys (and all sub-keys) to their own files, you could do this:
ECHO OFF
reg export HKLM hklm.reg > nul
reg export HKCU hkcu.reg > nul
reg export HKCR hkcr.reg > nul
reg export HKU hku.reg > nul
reg export HKCC hkcc.reg > nul
There is also a save
option, that does a similar thing but stores the data in a different format.
To simplify Mr. Roger Rowland's answer, we may execute this syntax within CMD.
C:\Users\MrCMD>FOR %K IN (LM CU CR U CC) DO @REG.EXE EXPORT HK%K hk%K.reg [enter]
Or do those more informative within Batch Script, we may named it "BUpRegWin.CMD"
@echo off
setlocal
for %%k in (lm cu cr u cc) do call :ExpReg %%k
goto :eof
:ExpReg
reg.exe export hk%1 hk%1.reg > nul
if "%errorlevel%"=="1" (
echo ^>^> Export --hk%1-- Failed.
) else (
echo ^>^> Export --hk%1-- Fine.
)
goto :eof
endlocal
Brighter ideas are welcome. Feel free to improve. Thank you in advanced. :) :) :)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With