Question Locked

Automate registry key removal

0 helpful
2 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.
I am trying to find out if there is a way to remove registry keys automatically Example being if i have a list of keys and locations in a correct path to key HKEY_LOCAL_MACHINE\SOFTWARE\Apple Computer, Inc.\iTunes like the lists created from registry monitoring software can i automate the removal of thousands of keys in a script. any help would be greatly appreciated

2 replies

by rob miners

The contents that could be saved as del.reg in the root directory c:\>

Windows Registry Editor Version 5.00

[-HKEY_LOCAL_MACHINE\SOFTWARE\Apple Computer, Inc.\iTunes]

This would delete the key iTunes and any keys below it.

The contents that could be saved as add.reg

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Apple Computer, Inc.\iTunes]

This will add the iTunes key back to the registry. It will not add what was deleted from underneath it.

This is how the batch file is structured EXAMPLE:

@echo on
C: regedit /s del.reg
goto s2

:S2
C: regedit /s add.reg

goto end

:END

OR as a stand alone batch file.

@echo on
C:
REG DELETE HKEY_LOCAL_MACHINE\SOFTWARE\Apple Computer, Inc.\iTunes

:: Deletes the registry key iTunes and its all subkeys and values
goto s2

:S2

REG ADD HKEY_LOCAL_MACHINE\SOFTWARE\Apple Computer, Inc.\iTunes

:: Will add the iTunes key back to the registry.
goto end

:END

This discussion is closed to new replies.