Article ID: 279847
This article was previously published under Q279847
Important This article contains information about how to modify the registry. Make sure to back up the registry before you modify it. Make sure that you know how to restore the registry if a problem occurs. For more information about how to back up, restore, and modify the registry, click the following article number to view the article in the Microsoft Knowledge Base:
(http://support.microsoft.com/kb/256986/ )Description of the Microsoft Windows registry
Windows Script Host (WSH) will return the error message
if an attempt is made to delete a key that contains subkeys.
Unable to remove registry key "<path to registry key>"
Windows Script Host does not have the capability to enumerate subkeys of a registry key.
One way to work around this problem is to use Windows Management Instrumentation to enumerate a registry key and modify any information necessary.
Another option is to use the ActiveX control RegObj.dll (see "References" for information about downloading this control).
Warning Serious problems might occur if you modify the registry incorrectly by using Registry Editor or by using another method. These problems might require that you reinstall your operating system. Microsoft cannot guarantee that these problems can be solved. Modify the registry at your own risk.
The following code demonstrates how to delete a registry key and all subkeys for that key:
The following sample code demonstrates how to use the ActiveX RebObj object to delete a registry key that has subkeys:
For more information about WMI, see the following MSDN Web site:
Article ID: 279847 - Last Review: September 3, 2012 - Revision: 4.0
Retired KB Content Disclaimer
This article was written about products for which Microsoft no longer offers support. Therefore, this article is offered "as is" and will no longer be updated.
Contact us for more help