views:

42

answers:

1

Hello,

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  A: 

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.

PA