Forum: Ruby windows registry delete value oddity

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
02bd6b98b7c04f9ae5868eda3d01fb73?d=identicon&s=25 Brad Tilley (rtilley)
on 2006-04-17 14:14
Say I have four registry values under the same key with these names:

1. 'this_text'
2. 'this_text1'
3. 'this_text2'
4. 'this_text3'

When I run the script below, two of the values will be deleted. When I
run it again, one value will be deleted. On the third run, the last
value will be deleted. I don't understand why all of the values are not
deleted on the first run.

Win32::Registry::HKEY_LOCAL_MACHINE.open(key,
Win32::Registry::KEY_ALL_ACCESS) do |reg|

  reg.each_value do |name, type, data|

    if name.include?('this_text')

      reg.delete_value(name)

    end

  end

end


Could someone point out what I'm doing wrong?

Thanks,
Brad
This topic is locked and can not be replied to.