Registry editing in Windows 7

I’m trying to edit 1 key in the Windows 7 registry and I’m having
trouble. Here’s what I have so far:

require ‘win32/registry’

keyname = ‘Software\Tightvnc\Server’
access = Win32::Registry::KEY_ALL_ACCESS, access) do |reg|
reg[‘Password’] = ‘7a,2f,07,fd,36,74,7c,52’

The key has a BINARY value that is already set to another value. When I
run the .rb file from an administrative command prompt it seems to run
with no errors, but the value never changes.

Hey Jason,

Try starting with a read operation so you know you’re interacting with
the expected registry. The wow32 node has caught me by surprise a few


Ok, this is weird. If I use

require ‘win32/registry’‘SOFTWARE\7-Zip’) do |reg|
value = reg[‘Path’] # read a value
puts value

I get “C:\Program Files\7-Zip” returned to the console which is
correct. However, if I try other keys to test, for example:

require ‘win32/registry’‘SOFTWARE\RegisteredApplications’)
do |reg|
value = reg[‘Paint’] # read a value
puts value

I get:

“C:/Ruby193/lib/ruby/1.9.1/win32/registry.rb:385:in `open’: The system
cannot find the file specified. (Win32::Registry::Error)”

The permissions appear to be set the same on both keys too.


If this is a 64 bit OS, you’re probably accessing the 32 bit registry by
default under the wow32 node. Take a look in there, find some specific
registry keys that are there and not in the 64 bit and you should be
able to verify.