Reputation: 1
I tried to find registry keys using this line:
REG Query HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Installer\UserData /F "Need removed manually Add-In" /S
But it contains these subkeys:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Installer\UserData\S-1-5-18\Components\145BA990C18DA984499E1D1F9A1BD64D
BB02C99E89C99CD4A8CC6A7AA7576194 REG_SZ C:\Program Files (x86)\Need removed manually Add-In\SimonFell\PocketSoap\psDime.dll
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Installer\UserData\S-1-5-18\Components\37AC9AD16C5204A4D9D92967A6699DEE
BB02C99E89C99CD4A8CC6A7AA7576194 REG_SZ C:\Program Files (x86)\Need removed manually Add-In\SimonFell\PocketSoap\pSOAP32.dll
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Installer\UserData\S-1-5-18\Components\DFD1C740E6047204C8387A02138B234A
BB02C99E89C99CD4A8CC6A7AA7576194 REG_SZ C:\Program Files (x86)\Need removed manually Add-In\SimonFell\PocketSoap\pocketHTTP.dll
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Installer\UserData\S-1-5-18\Components\F3A3DDBA307ACB945868E32C44414A5E
BB02C99E89C99CD4A8CC6A7AA7576194 REG_SZ C:\Program Files (x86)\Need removed manually Add-In\SimonFell\PocketSoap\psProxy.dll
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Installer\UserData\S-1-5-18\Products\BB02C99E89C99CD4A8CC6A7AA7576194\InstallProperties
DisplayName REG_SZ Need removed manually Add-In
End of search: 5 match(es) found.
When I tried to delete using with a script:
FOR /f "delims=" %%a IN ('REG Query HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Installer\UserData /F "Need removed manually Add-In" /S') DO REG delete "%%a" /f
I delete first full key successful but after I that, I get an error because the script is trying to delete the second line with string detail:
REG delete "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Installer\UserData\S-1-5-18\Components\145BA990C18DA984499E1D1F9A1BD64D" /f
The operation completed successfully.
REG delete " BB02C99E89C99CD4A8CC6A7AA7576194 REG_SZ C:\Program Files (x86)\Need removed manually Add-In\SimonFell\PocketSoap\psDime.dll" /f
ERROR: Invalid key name. Type "REG DELETE /?" for usage.
How can I delete only the actual keys and avoid this error?
Upvotes: 0
Views: 769
Reputation: 38622
Here's my response as provided belatedly in the duplicate question.
Use the Reg Query
search option, /F
, and search in data values only, /D
, Then to remove the value lines and the search count you can use Find
to output only those lines containing the string HKEY_
.
@Echo Off
Set "Key=HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Installer\UserData"
Set "Str=Need removed manually Add-In"
For /F "Delims=" %%A In ('REG Query "%Key%" /S /F "%Str%" /D^|Find "HKEY_"'
) Do Echo=Reg Delete "%%A" /F
Pause
Change the values in lines 2
and 3
to suit your specific requirements.
If you're happy with the output, simply remove Echo=
from the penultimate line and optionally remove the last line. (Please note that I don't recommend deleting registry keys in this manner so the decision is yours as to whether you should have a registry backup prior to deleting these keys)
Note that you may need to Run as Administrator to delete keys under HKLM
.
Upvotes: 0