I need a batch file to search and delete registry subkeys

I want to search HKLMSoftwareMicrosoftWindows NTProfileList and delete any subkeys that end in ".bak". I can only come up with this much of it:for /F %%a in ('reg query HKLMSoftwareMicrosoftWindows NTProfileList') DO reg delete %%a

Try this; it's in test mode and will only echo the "reg delete" commands it would normally run. Remove the uppercase ECHO in line 6 to run it for real.

Try this; it's in test mode and will only echo the "reg delete" commands it would normally run. Remove the uppercase ECHO in line 6 to run it for real.