开发者

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

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)?


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜