I want to search and delete some registry keys. These keys may vary in address, but their names are fixed like below:
{1F5093-119-4c0-B05-658A23EC4B}
{C04056-35F-4b8-A3A-9F098E503D}
{978DBB-DCA-42e-B40-6591221CD3}
{CC93C6-D33-4ac-AFA-50075D4893}
Currently, I can search for them and write to a new file by command below, but there are two problems, first, It only searches in one directory either HKU, or HKLM or HKCU, or ... ; second, how to write another batch file to read found addresses and delete these keys?
REG Query HKU /f {1F7B5093-119B-4c50-B705-658A231CEC4B} /s > "out.bat"
If I can read lines in out.bat, the keys could be easily deleted by [-reg.address]
Use for
loops:
@echo off
for %%a in (HKLM HKU) do (
for %%b in (
"{1F5093-119-4c0-B05-658A23EC4B}"
"{C04056-35F-4b8-A3A-9F098E503D}"
"{978DBB-DCA-42e-B40-6591221CD3}"
"{CC93C6-D33-4ac-AFA-50075D4893}"
) do (
echo Searching %%a for %%~b...
for /f "delims=" %%c in ('
reg query %%a /s /k /f "%%~b" ^| findstr /b "HKEY"
') do (
echo Deleting %%c
reg delete "%%c" /f >nul
)
)
)
pause