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
thanks.
Be sure to use the option ‘/f’ after the key as mentioned in the post. using it in wrong place errors out saying ‘invalid option’
Correct usage is
You’re absolutely right. This is because “reg” needs a value from the set that has words such as “delete,” “add,” and “compare.”
As for “delete,” it (like “add”) needs a path (e.g. HKCU\SomeKey).
1) it works thanks
2) it does not work
(how to make it in remote pc , i know the password and user, if it is needed)
I think it implicitly tries to use the current logged in user credentials.
Try doing net use to the remote host before running reg delete.
How can I delete remote registry with space path?
Did you try enclosing it in quotes like below?
It’s working great base on your advice. Anyway, I still need to delete a registry key value with space, something example ‘Test This’ in
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run
Thanks in advance.
Regards,
You can wrap the value name also in double quotes to make it work with space. For example the below command would work for the example case.
sorry, the value in space(key name with space), not key value
Hi. What about a key that has quotes in the key name? I can’t get it to work, I don’t know how it expects me to escape the quotes.
eg:
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\ShellIconOverlayIdentifiers\”DropboxExt1″]
ASUS laptop crashes on every boot. BSOD. tried f8, safe mode with command prompt; every option offered there starts and then returns to BSOD. MS repair says it “cannot make the necessary repairs”. Repair report says: “Registry is corrupt” Fix: “Registry rollback”. Laptop will not boot to CD/DVD drive, though I have used f12 to change boot config. The UBCD4WIN disk is useless there as well as all repair disks and Windows Repair disks. So I can’t fix corrupted registry with commands.
So…I pulled the SATA drive, attached USB 2.0 interface cable, and am now trying to repair the registry from another windows (10) laptop. I open a CMD window and have the ASUS drive, (drive F) ready for the proper command sequence; if there is one. Or perhaps you know of a program on some website, that I can download to my Windows 10 laptop, that will do it for me.
Option 2: re-format the drive and re-install it, and hope that the computer automatically re-installs Windows 7?
Option 3: Fork over the money for a new windows 10 laptop?
Any ideas?
Thanks in advance for your help,
Erich
As a follow up to the previous post; I found MSIEXEC and wonder if that command can be used to perform an automatic registry repair?
Thanks again,
Thanks a lot for the fix and help. Will see if this error does not show again!
Thanks,
Roberto
Thanks
Thanks a lot! Helpful!
how can i delete key for old printers so the default printer remains the same
what if I want to delete multiple keys?
thanks!
Removing (I use 1709 version) I have “access denied”. Only administrator can do.
Is there a way to enable user (my user is admin)?
Thx very helpull collection!!
Is it possible to add auto refresh of the registry at the end of a bat file??
I want to delete a key + key tree with a bat file.
Example:
REG Delete “HKEY_CURRENT_USER\Software\WinRAR” /f
I run this in a bat file, the key is deleted correctly as requested, but on the Registry Windows, the key is still appearing. I must do a Refresh or F5, for it to desappear.
So I would like the bat file to do: Delete or the key + Refresh of itself.
Thx you ))
Excellent and this really helped me out for over 100 machines.
regards
How we can delete all the registry key under HKCR?
I tried below but not working
reg delete “HKCR” /f