SOLVED: Command Line Script To Delete a Registry Entry

We often talk about editing or creating new registry entries in Windows but we seldom talk about removal.  If you want to delete an existing registry entry you simply set the entry value to a hyphen ( – ).

For example, we recently needed to delete:

HKLM > SOFTWARE > Microsoft > Windows > CurrentVersion > Run > InstallWindowsUpdates = DWORD AA

To do this we simply set “InstallWindowsUpdates”=-

Specifically, the DELUPDATES.REG file looked like:

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run]
“InstallWindowsUpdates”=-

We scripted this to install silently using the switch /S

regedit.exe /S \\fileserver\scripts\DELUPDATES.REG

and we pushed this command to the desired computers using PDQ so it would run locally as an administrator.

If you wanted to delete the entire key you would use:

[-HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run]

which would make your reg file look like:

Windows Registry Editor Version 5.00

[-HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run]

For more information see THIS Microsoft article.

 

Share This With Your Friends Now:
Facebooktwittergoogle_plusredditpinterestlinkedin

Leave a Reply

Your email address will not be published.

Name *
Email *
Website