archrival Posted May 3, 2007 Posted May 3, 2007 When using RegDelete, I am unable to delete registry keys if they contain children. I have to delete all of the children first before I am able to delete the parent. This happens on my X64 box, the same code works on X86. The keys I'm trying to delete lie in HKEY_LOCAL_MACHINE\Wow6432Node\Software, using RegDelete('HKLM\Software\keyname') it fails because 'HKLM\Software\keyname\childkeyname' exists. Is this intended behavior? In this situation, @error is set to -2. I am able to delete childkeyname and then keyname in that order. I don't mind being forced to enumerate all child keys, but I don't want to use WMI.
The Kandie Man Posted May 9, 2007 Posted May 9, 2007 (edited) Same thing happens on my x64 box. - The Kandie Man ;-) Edited May 9, 2007 by The Kandie Man "So man has sown the wind and reaped the world. Perhaps in the next few hours there will no remembrance of the past and no hope for the future that might have been." & _"All the works of man will be consumed in the great fire after which he was created." & _"And if there is a future for man, insensitive as he is, proud and defiant in his pursuit of power, let him resolve to live it lovingly, for he knows well how to do so." & _"Then he may say once more, 'Truly the light is sweet, and what a pleasant thing it is for the eyes to see the sun.'" - The Day the Earth Caught Fire
GEOSoft Posted May 9, 2007 Posted May 9, 2007 When using RegDelete, I am unable to delete registry keys if they contain children. I have to delete all of the children first before I am able to delete the parent. This happens on my X64 box, the same code works on X86. The keys I'm trying to delete lie in HKEY_LOCAL_MACHINE\Wow6432Node\Software, using RegDelete('HKLM\Software\keyname') it fails because 'HKLM\Software\keyname\childkeyname' exists. Is this intended behavior? In this situation, @error is set to -2. I am able to delete childkeyname and then keyname in that order. I don't mind being forced to enumerate all child keys, but I don't want to use WMI.Carefully read RegEnumKey()Hint: You might need to use HKLM64 George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!"
archrival Posted May 10, 2007 Author Posted May 10, 2007 Carefully read RegEnumKey()Hint: You might need to use HKLM64I am able to delete the children first, then the parent. It's not that I can't delete the keys, I would just need to cycle through all children and grandchildren registry keys before I am able to delete the parent key. I started to look at the RegKeyDelete function in advapi32.dll, but I didn't try too hard yet.
PartyPooper Posted May 10, 2007 Posted May 10, 2007 You may need to use RegEnumKey to help create a RegDelete loop before deleting the parent.
archrival Posted May 12, 2007 Author Posted May 12, 2007 I figured out how to do this by the way. DllCall("shlwapi.dll", "long", "SHDeleteKey", "long", 2147483650, "string", "Software\\Test")
autoitaddicted Posted March 7, 2012 Posted March 7, 2012 I think i know why this is happenning. Because you've deleted a key in loop, automaticly it's number decreasing but your loop still increasing. so doing something like this will probably solve the problem: For $i = 1 to 100 $var = RegEnumVal("HKLM"& $mimari&"SOFTWAREMicrosoftInternet ExplorerToolbar", $i) If @error <> 0 Then ExitLoop $read = RegRead("HKLM"& $mimari &"SOFTWAREMicrosoftInternet ExplorerToolbar", $var) $result_no = StringInStr($var, "Locked") $result_yes = StringInStr($var, "-") if $result_no == 0 and $result_yes > 0 Then MsgBox(4096, "durum", $read & " - read var -" & $var) $result = RegDelete("HKLM"& $mimari &"SOFTWAREMicrosoftInternet ExplorerToolbar", $var) $i = $i-1 ; this is needed for right iteration because you have already deleted one MsgBox(4096, "durum", $result) EndIf Next I know thread is old but while i'm googling i saw this and suddenly realized the solution.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now