For/in/do question relating to Registry Backup (XP)
Posted: 18 May 2023 10:17
Hi All,
I was wondering whether a kindly soul would help me out with a interesting section of batch code (for XP as far as I know) which employs for-in-do, it backs up registry keys the code & is as follows, I found it elsewhere on the net but it does have potential:
"Error: Invalid Command-Line parameters" on each line of HKLM HKCU HKCR HKU HKCC output also the C:\Temp does get created but the contents of C:\temp are zero. I basically have 4 ?'s
Regards,
David
I was wondering whether a kindly soul would help me out with a interesting section of batch code (for XP as far as I know) which employs for-in-do, it backs up registry keys the code & is as follows, I found it elsewhere on the net but it does have potential:
However I know this code is busted or wrong as the error it spits out in CMD@echo off
setlocal
set BackupFolder=C:\Temp
if not exist "%BackupFolder%" md "%BackupFolder%"
for %%a in (HKLM HKCU HKCR HKU HKCC) do (
echo Exporting %%a to %BackupFolder%\%%a.reg ...
%Systemroot%\system32\reg.exe export "%%a" "%BackupFolder%\%%a.reg" /y
)
pause
"Error: Invalid Command-Line parameters" on each line of HKLM HKCU HKCR HKU HKCC output also the C:\Temp does get created but the contents of C:\temp are zero. I basically have 4 ?'s
- How can I get this above "export" code to work, I cannot see where the error is?
- What would I use in terms of code to "Import" or to restore the resultant backed up registry?
- Is there an error-level log check that could be employed to identify if the routine has been successful?
- There is reference to others comments on the net that say that this method of registry backup is not a good idea as there are special permissions needed when reinstating the registry & this type of procedure could choke or fail. I would be interested others opinions in this question?
Regards,
David