0

I need to Delete selected subkeys in a registry key. For one of the subkeys I need to delete I tried:

(SET _KEY=SOFTWARE\Microsoft\Windows\CurrentVersion\UFH\SHC)
REG Delete "HKCU\%_KEY%" /V "C:\ProgramData\Microsoft\Windows\Start      Menu\Programs\UltraVNC\UltraVNC Viewer\UltraVNC Viewer (Listen Mode  Encrypt)).lnk
C:\Program Files\uvnc bvba\UltraVNC\vncviewer.exe
-dsmplugin SecureVNCPlugin64.dsm -listen 5500
" /f

And it asked me (Y or N)

I know it didn't work because it shouldn't have asked (Y or N) because I have /f. I think the problem is the subkey has multiple lines. I have about 60 subkeys that I need to delete under this Key. All the sub keys I need to delete have "uvnc bvba" in the subkey. It would be nice to have a for loop to find the right ones to delete.

Docfxit
  • 11
  • 4

1 Answers1

0

I think I figured out how to answer my own question.

@Echo Off
Set "Key=HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\UFH\SHC"
Set "Str=uvnc bvba"
setlocal EnableExtensions DisableDelayedExpansion
for /F "EOL=E Delims=" %%I in ('@%SystemRoot%\System32\reg.exe query "%Key%" /v * ^| find "%Str%"') do (Echo=reg   delete "%Key%" /v "%%~I" /f 2>nul
if not errorlevel 1 echo Deleted "%%~I" from %Key%
)
endlocal

cmd /k

I'd welcome any comments if I am doing something wrong or there is a better way of doing it.

Docfxit
  • 11
  • 4