Reputation: 1
I wonder if it's possible to find and delete certain given registry values by the user in the Windows registry with a bat file.
For example, I want to delete all the entries which contains the word oracle
, so the bat file must delete all the entries like for example:
c:\users\user\AppData\LocalLow\Oracle\Java\jre1.8.0_101\
Microsoft OLE DB Provider for Oracle
c:\oracle\product\11.2.0\client_1\bin\OraOLEDB11.DLL
As you can see, the 3 entries have the word oracle
in it. Is this possible?
Thank you very much!
Upvotes: 0
Views: 5841
Reputation: 5631
There are 2 commands that will fit your requirements: reg query
and reg delete
.
With req query
you can search for keys and/or values in the registry.
reg query <KeyName> [{/v <ValueName> | /ve}] [/s] [/se <Separator>] [/f <Data>] [{/k | /d}] [/c] [/e] [/t <Type>] [/z]
The following example searching recursive (/s
) in HKCU
:
reg query HKCU /s /f Oracle
To delete a registry key or value use reg delete
:
Reg delete <KeyName> [{/v ValueName | /ve | /va}] [/f]
To write it in a batch you have to filter the output of reg query
a bit and parse it line by line with a for /F
loop. If you have trouble with that show your efforts and ask about specific problems (edit your question).
Also consider of making a backup with reg export
of selected keys before you delete them.
Reg export KeyName FileName [/y]
Another great tool for such things is the PowerShell.
Upvotes: 2