JSI Tip 9986. How can I delete my registry Favorites from the command line?

In tip 4081, I explained how to get Regedit to remember your frequently uses registry paths.

Using REG.EXE, built into Windows XP and Windows Server 2003, or REG.EXE from the Windows 2000 Support Tools on the CD-ROM, I have scripted RegFavDel.bat to delete one, or all, of your registry Favorites.

The syntax for using RegFavDel.bat is:

RegFavDel Favorite|ALL

Where Favorite is the name of the favorite that you wish to delete, or ALL to delete all the Favorites.

RegFavDel.bat contains:

@echo off
if \{%1\}==\{\} @echo Syntax: RegFavDel Favorite^|ALL&goto :EOF
set key=%1
set key=%key:"=%
set qry=HKCU\Software\Microsoft\Windows\CurrentVersion\Applets\Regedit\Favorites
if /i "%key%" EQU "ALL" goto delall
for /f "Tokens=*" %%a in ('reg query %qry%^|FIND "REG_SZ"') do (
 call :strip "%%a">nul 2>&1
goto :EOF
call :delallq>nul 2>&1
goto :EOF
reg DELETE %qry% /F
reg ADD %qry%
goto :EOF
set line=%1
set line=%line:"=%
set work=%line%
set work=%work:*REG_SZ=REG_SZ%
call set fav=%%line:%work%=%%
for /f "Tokens=1-8" %%i in ('@echo %fav%') do (
 set subkey=%%i %%j %%k %%l %%m %%n %%o %%p
set subkey=%subkey:  =%#
set subkey=%subkey: #=%
set subkey=%subkey:#=%
if /i "%key%" NEQ "%subkey%" goto :EOF
reg DELETE %qry% /V "%subkey%" /F

Hide comments


  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.