批处理文件 - 搜索和编辑注册表? [英] batch file - searching and editing registry?
本文介绍了批处理文件 - 搜索和编辑注册表?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我要搜索并删除某些注册表项。这些键可以在地址不尽相同,但他们的名字都是固定的象下面这样:
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}
目前,我可以搜索他们,并写入由以下命令创建一个新文件,但有两个问题,第一,它仅搜索在一个目录无论是香港大学,或HKLM或HKCU,或...;第二,如何写另一个批处理文件读取找到的地址,并删除这些注册表项?
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"
如果我可以阅读out.bat线,键可以很容易地通过删除[ - reg.address]
If I can read lines in out.bat, the keys could be easily deleted by [-reg.address]
推荐答案
使用为
循环:
@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
这篇关于批处理文件 - 搜索和编辑注册表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文