Welcome to Windows 7 Forums. Our forum is dedicated to helping you find support and solutions for any problems regarding your Windows 7 PC be it Dell, HP, Acer, Asus or a custom build. We also provide an extensive Windows 7 tutorial section that covers a wide range of tips and tricks.

# Windows 7: Any way to automate deleting lots of keys from the registry?

 14 Mar 2015 #1 WebMaximus Windows 7 Ultimate x64 39 posts Any way to automate deleting lots of keys from the registry? Does anyone know if there's some freeware tool that would allow me to delete lots of keys from the registry under a specific hive containing a string value which in turn contains a specific value? Below is a short extract from my registry where I exported the hive of interest and as you can see some of the keys contain a string containing the value 'Microsoft Flight simulator X' Code: [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Installer\UserData\S-1-5-18\Components\DB458B8A779B8B9D6853499E99DC17B6] "5F30FE2770501684A9449DF94D4C4181"="C:\\Program Files\\Paint.NET\\Resources\\it\\Files.AboutCredits.rtf" [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Installer\UserData\S-1-5-18\Components\DB4C64BA715DB0E45A96CE93457A0ABF] "3BB6B5B440AD65B4EA71DDFBF3448688"="" [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Installer\UserData\S-1-5-18\Components\DB5A057B2C8023D4C88B5811F98BC4C5] "9040580900063D11C8EF10054038389C"="C:\\Program Files (x86)\\Microsoft Office\\OFFICE11\\UCSCRIBE.DLL" [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Installer\UserData\S-1-5-18\Components\DB5A057B2C8023D4C88B5811F98BC4C5\9040580900063D11C8EF10054038389C] "PatchGUID"="{5798D425-7593-4FE5-BE53-E60DEBB65A53}" "MediaCabinet"="PCW_CAB_H15000_1" "File"="UCSCRIBE.DLL_0002" "ComponentVersion"="11.0.8161.0" "ProductVersion"="11.0.6506" "PatchSize"="0" "PatchAttributes"="0" "PatchSequence"="10010" "SharedComponent"="0" "IsFullFile"="1" [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Installer\UserData\S-1-5-18\Components\DB61AF379CDB76047BD6318B9D421FCF] "694A72599FD5A214DA7C61B85A73C96A"="F:\\Program Files (x86)\\Microsoft Games\\Microsoft Flight Simulator X\\SimObjects\\Airplanes\\Grumman_Goose_G21A\\Texture.1\\Fresnel_Ramp.dds" [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Installer\UserData\S-1-5-18\Components\DB6BCDDA824074D448EC6F57C30142DA] "694A72599FD5A214DA7C61B85A73C96A"="F:\\Program Files (x86)\\Microsoft Games\\Microsoft Flight Simulator X\\SimObjects\\GroundVehicles\\VEH_Air_FireTruck_Euro_sm\\sim.cfg" [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Installer\UserData\S-1-5-18\Components\DB6E9B4033F985670CF18C3B9B1A1EE8] "c1c4f01781cc94c4c8fb1542c0981a2a"="" "1D7AD0FA68A03E11788E0FD42AA3C585"="" "b25099274a207264182f8181add555d0"="" [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Installer\UserData\S-1-5-18\Components\DB6FEC9342BC5F9439DC375AAE2D7702] "694A72599FD5A214DA7C61B85A73C96A"="F:\\Program Files (x86)\\Microsoft Games\\Microsoft Flight Simulator X\\SimObjects\\Airplanes\\Bombardier_CRJ_700\\panel\\Bombardier_CRJ_700.cab" [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Installer\UserData\S-1-5-18\Components\DB7673335BBD6FF489B241C29C3977FC] "D3C479BC101D1144F845CDCD85ED8D51"="C:\\Program Files\\Protector Suite\\Interop.WMPLib.dll" [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Installer\UserData\S-1-5-18\Components\DB7949BC483A8973F71343A37A9FC425] "5F30FE2770501684A9449DF94D4C4181"="C:\\Program Files\\Paint.NET\\Resources\\en-US\\Icons.InvertColorsEffect.png" So...what I would like looking at the example above is to find a tool where I could simply tell it to go through the complete HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Installer\UserData\S-1-5-18\Components hive and delete any keys containing a string value containing Microsoft Flight Simulator X. Of course I could do this clean-up myself manually but it will take some time considering the number of entries to remove so if there's a tool of some kind that could do this for me I would be more than happy. Thanks in advance for any tips! My System Specs
 .
 14 Mar 2015 #2 Wandering one Win7 sp1 Pro 64bit / XP sp2 Pro (games only) 227 posts Osoyoos B.C. More than likely C Cleaner will do if the program is uninstalled. Next time Revo uninstaller is better for uninstalling as it also checks for registry left overs. Don't neglect to select reg backup before it is too late. Art. My System Specs
 14 Mar 2015 #3 WebMaximus Windows 7 Ultimate x64 39 posts Already tried CCLeaner but unfortunately it didn't find these keys. Thanks for the tip regarding Revo. My System Specs
 .
 14 Mar 2015 #4 Ztruker Windows 10 Pro X64 6,291 posts Space Coast of Florida Give RegSeeker a try. You can search specific chains, like HKEY_LOCAL_MACHINE for spoecific text. When done, simply select all then right click and delete. It will also backup the entries before deleting them. My System Specs
 14 Mar 2015 #5 WebMaximus Windows 7 Ultimate x64 39 posts Quote: Originally Posted by Ztruker Give RegSeeker a try. You can search specific chains, like HKEY_LOCAL_MACHINE for spoecific text. When done, simply select all then right click and delete. It will also backup the entries before deleting them. Many thanks, will give it a try! My System Specs
14 Mar 2015   #6
Pyprohly

Windows 10, Windows 8.1 Pro, Windows 7 Professional, OS X El Capitan

Hi WebMaximus,

Attached is a batch script solution you can try. Running the script will display the keys that will be deleted after matching the given string. Change the "WhatIf" value, in the batch file, to FALSE to instead delete found keys.

Note: Modifying the HKLM hive requires Administrator rights, so the batch file must be run from an Elevated Command Prompt.

Preview:
Code:
@echo off
net session >NUL 2>&1|| echo Error: deleting from the HKLM hive requires Administrator privilages.&& timeout 2 >NUL && exit /b 1

REM Iterate through %starting_key% and delete any child keys
REM that contain the string %string_to_find% in any value of
REM the key.

::
set starting_key="HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Installer\UserData\S-1-5-18\Components"
set string_to_find="Microsoft Flight simulator X"
set should_recurse=FALSE
set prompt_before_deletion=TRUE
set WhatIf=TRUE
::

set echo=& if /i not "%WHATIF%"=="FALSE" set "echo=ECHO"
set should_recurse=& if /i "%SHOULD_RECURSE%"=="TRUE" set "recurse=/s"
set prompt_before_deletion=/f& if /i "%PROMPT_BEFORE_DELETION%"=="TRUE" set "prompt_before_deletion="
echo This may take a moment...& echo.
for /f "delims=" %%A in (' reg query "%STARTING_KEY:"=%" %RECURSE% ') do (
for /f "delims=" %%B in (' reg query "%%~A" /v "*" ') do (
echo "%%~B"| find /i "%STRING_TO_FIND:"=%" >NUL && (
if defined ECHO (
echo "%%~A"& echo.
) else (
reg delete "%%~A" %PROMPT_BEFORE_DELETION%& echo.
)
)
)
)
echo Done.

Attached Files
 th-364156.bat (1.1 KB, 2 views)
My System Specs
 16 Mar 2015 #7 WebMaximus Windows 7 Ultimate x64 39 posts Just wanted to say thanks to all of you guys for your help and valuable input! I ended up using a combination of manual cleaning up with help from RegSeeker. RegSeeker to easy find and delete the entries in my example above and manual clean-up of some additional entries. Could have used RegSeeker for those as well but in some cases I found it more easy to manually search the registry using regedit to identify keys and values I wanted to get rid of. My System Specs