How to find/delete a string value in the registry based on its value

最后都变了- 提交于 2019-12-24 16:09:45

问题


I am trying to write a .reg file that would take a given key, and search for a string value based on its contents, and then delete it. For example:

[path]
"a"="b"
"z"="y"
"foo"="bar"

And somehow delete the value "foo" by knowing either "bar" or a substring of that. Is this possible? Would I need to do this in a .bat script (which is fine, btw)?


回答1:


try this in a BAT file

SET KEY=HKLM\Software\MySoftware\Path
SET VALUE=BAR
for /F "tokens=1,*" %%a in ('REG QUERY "%KEY%" ^| findstr /I /C:"%VALUE%"') do (echo REG DELETE "%KEY%" /v %%a)

and after extra careful testing remove the ECHO.



来源:https://stackoverflow.com/questions/3323388/how-to-find-delete-a-string-value-in-the-registry-based-on-its-value

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!