Search code examples
rubywindowsregistry

How to add a new dword (32-bit) value in registry using ruby?


I need to add a new dword (32-bit) value '1001' in the following registry path:

path = "Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings\\Zones\\3\\" 

After adding, the registry structure should look like this: enter image description here

How can achieve the same using ruby?


Solution

  • Following lines solved the problem for me.

        Win32::Registry::HKEY_CURRENT_USER.create(path) do |reg|
           reg.write('1001', Win32::Registry::REG_DWORD, 0)
        end
    

    Here I'm setting the value 0 for newly created dword (32-bit) value '1001' in registry.