|Is it possible to delete a registry key only if it exists with a batch file?|
For example, I would like to completely delete the following registry keys 'KeyName' without confirmation.
REG DELETE "HKCU\Software\CompanyName\ProductName\KeyName" /F
REG DELETE "HKLM\SOFTWARE\CompanyName\ProductName\KeyName" /F
REG DELETE "HKCU\Software\Wow6432Node\CompanyName\ProductName\KeyName" /F
REG DELETE "HKLM\SOFTWARE\Wow6432Node\CompanyName\ProductName\KeyName" /F
The above works in simply deleting the keys.
Is it possible to attempt such deleting only if each key exists? Also, if the key exists is deleted is it possible to echo a success message for that key?
Basically, I would like a batch to only delete a key if it exists without confirmation then echo a success message for that deleted key.
Thanks in advance for any help.