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
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
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
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
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