Delete Registry key from command line

by admin on November 17, 2010

Reg command allows us to delete registry keys and registry values from command line. This reg command can be used from batch files also. The syntax for the delete operation is explained below with examples.

Delete a registry value

reg delete  Registry_key_path /v Registry_value_name

Example:

Delete the registry value ‘CleanShutdown‘ under the key ‘HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer

c:\> reg delete HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer /v CleanShutdown
Delete the registry value CleanShutdown (Yes/No)? yes
The operation completed successfully.

If you want to delete registry key without being prompted for confirmation then add /f switch to the command.

reg delete  Registry_key_path /v Registry_value_name /f

Example:
For the above example, the command to delete the registry value without any confirmation prompt:

c:\> reg delete HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer /v CleanShutdown  /f
The operation completed successfully.

If the registry key has space in its name, you can use double quotes as below.

reg delete "Registry_key_path" /v Registry_value_name /f

Example:
Command to delete the registry value ‘TSAdvertise‘ under the registry key ‘HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Terminal Server’

reg delete "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Terminal Server" /v TSAdvertise /f

Delete a registry key

Delete all registry keys and values under a registry key:

reg delete Registry_key_path

Example:
Delete all the registry values under the key ‘HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Applets\Regedit\Favorites’

reg delete HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Applets\Regedit\Favorites

Delete all registry values under a registry key

 reg delete RegistryKey  /va

{ 1 comment… read it below or add one }

keanoosh January 29, 2013 at 7:18 am

thanks.

Reply

Leave a Comment

HTML tags are not allowed.

Previous post:

Next post: