Old 13th April 2018, 21:36   #1
pkonduru
Member
 
Join Date: Jul 2015
Posts: 62
Enumeration weird behaviour

Hi everyone!

I am seeing this really weird behavior when using an enumeration. Maybe a second pair of eyes will see what wrong I am doing. So I am basically looping through a registry and if I find the key I am looking for I delete it. When I run the below script to just show me what keys match(say there are 2), it works perfectly fine. The message box shows up twice with the correct key that I am looking for.
Now when I uncomment the line where it actually deletes the key, it only deletes one of the keys and exits out. I have tried all sorts of debugging with message boxes, but I am not able to figure out why it would not delete both the keys.

loop:
EnumRegKey $1 HKLM SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall $0
StrCmp $1 "" done
${StrContains} $R1 "MyString" "$1"
StrCmp $R1 "" notfound
StrCpy $regKeyDelete $1
MessageBox MB_OK 'Found string $regKeyDelete'
;DeleteRegKey HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$regKeyDelete"

notfound:
IntOp $0 $0 + 1
goto loop
done:
pkonduru is offline   Reply With Quote
Old 13th April 2018, 22:39   #2
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 4,888
Reset the index $0 to 0 every time you delete a key. The order of enumerated keys is not documented in Windows.

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Old 13th April 2018, 23:11   #3
pkonduru
Member
 
Join Date: Jul 2015
Posts: 62
Awesome!! thanks Anders!!
pkonduru 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