Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Cannot delete registry key if it has a subkey 1

Status
Not open for further replies.

tfujitani

Programmer
Nov 5, 2002
6
US
When I use the following to delete a registry key:

Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.RegDelete "HKLM\SOFTWARE\ODBC\ODBC.INI\"

It won't delete the registry key if there is a subkey (for example; "HKLM\SOFTWARE\ODBC\ODBC.INI\Test"). Is there a way to delete a registry key and all of its subkeys without having to delete the subkeys first?
 
On Win9x systems, you can delete a registry key that has subkeys but on NT
systems, you must delete the subkeys first. The Win9x and NT platforms have
different implementations of the registry API.
 
shaneh0 it totally correct and deserves a star, i have looked at wmi documentation on this but i guess they all use the same api calls in the end.
no choice but to call the delete key recursively after using wmi to enumerate recursively,,,sounds very ugly. but i guess if you are really seriuos about deleting all subkeys then you will probably know which ones are there before you start
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top