Old 16th September 2009, 14:20   #1
JoeAcunzo
Junior Member
 
Join Date: Feb 2004
Posts: 29
DeleteRegKey Fails Because Not Iterating All Subkeys

I call DeleteRegKey in an Uninstall section and it fails to remove the registry key. Looking at the registry after the uninstall, only one of four subkeys has been deleted, which explains the failure. Using sysinternals Process Monitor, I see that it iterates the subkeys, but stops on the first one. Oddly, after it has deleted and closed the first subkey, it then tries to reopen that same subkey, which of course fails because it does not exist any longer. It's almost as if it tries to process the same subkey a second time instead of moving on to the next subkey.

A few more twists. This exact same script code worked fine when compiled with a version of NSIS prior to 2.39 (not sure exactly which version), but now fails with the latest version 2.45. Also, this is failing on Vista, but working on XP (again, used to work on both Vista and XP with a prior NSIS version). Note that I do use "RequestExecutionLevel admin" in my script, so I don't believe it's a elevation level issue. Lastly, I copied/pasted out the problem area of my script and created a test script. That test script works fine.

Here is a snippet of the code:

code:

; Must first remove the deny permission on Globals.
AccessControl::GrantOnRegKey HKLM "Software\SoftwareTime\ComputerTime\Globals" "(S-1-5-32-545)" "EnumerateSubKeys"
ClearErrors
DeleteRegKey HKLM "Software\SoftwareTime\ComputerTime"
${If} ${Errors}
MessageBox MB_OK "Error removing registry key."
${EndIf}

JoeAcunzo is offline   Reply With Quote
Old 17th September 2009, 14:39   #2
kichik
M.I.A.
[NSIS Dev, Mod]
 
kichik's Avatar
 
Join Date: Oct 2001
Location: Israel
Posts: 11,343
Vista adds extra fun with virtual registries. Did you add a manifest using RequestExecutionLevel? If you did, make sure you have permission to delete those keys and make sure there isn't another copy of it somewhere else in the registry.

NSIS FAQ | NSIS Home Page | Donate $
"I hear and I forget. I see and I remember. I do and I understand." -- Confucius
kichik is offline   Reply With Quote
Old 22nd September 2009, 19:48   #3
JoeAcunzo
Junior Member
 
Join Date: Feb 2004
Posts: 29
Yes, I did use RequestExecutionLevel, and keep in mind this same exact script worked with an earlier version of NSIS, but fails with version 2.45.

Here's the important part -- I looked at the NSIS C source code and compared it to the Process Monitor output that shows events on the registry. In exechead\exec.c\myDeleteRegKeyEx(), it does not recurse into itself for each subkey according to the output log of Process Monitor, very odd. So it appears to be an issue at the level below my script in the runtime engine of NSIS itself.

However, in a smaller test script, it *does* recurse properly into itself on each subkey. I am totally baffled and looking for suggestions as what to try next. Thanks!
JoeAcunzo is offline   Reply With Quote
Old 19th October 2012, 12:14   #4
PoRtAbLe_StEaLtH
Junior Member
 
Join Date: Jul 2011
Posts: 49
i know this is an old post.. but is the closest post that is relevant to my question.

is there a recursive switch for AccessControl?
SetACL has
PHP Code:
-rec 
i looked through AccessControl's documents but didn't see anything.
PoRtAbLe_StEaLtH is offline   Reply With Quote
Old 19th October 2012, 19:35   #5
MSG
Major Dude
 
Join Date: Oct 2006
Posts: 1,892
If it's not in the documentation, it's probably not in the plugin either. Of course you're more than welcome to modify the accesscontrol plugin, and submit a patch for the code to the bug tracker.
MSG is offline   Reply With Quote
Old 20th October 2012, 10:22   #6
PoRtAbLe_StEaLtH
Junior Member
 
Join Date: Jul 2011
Posts: 49
thank you for answering.

i wasn't sure if there was a trick or something to make it work recursively that wasn't documented.

thanks again.
PoRtAbLe_StEaLtH is offline   Reply With Quote
Reply
Go Back   Winamp & Shoutcast Forums > Developer Center > NSIS Discussion

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump