Thanks Adam for the useful links.
I am trying to execute this code from a recipe to get the values of registry
require 'win32/registry'
keynameComp=
"SYSTEM\CurrentControlSet\Control\computername\computername"
keynameActive=
"SYSTEM\CurrentControlSet\Control\computername\activecomputername"
compName = ""
compNameActive = ""
access =Win32::Registry::KEY_ALL_ACCESS
Win32::Registry::HKEY_LOCAL_MACHINE.open(keynameComp, KEY_READ) do |reg|
reg.each{|name, value, keys | compName = keys}
end
::Win32::Registry::HKEY_LOCAL_MACHINE.open(keynameActive, KEY_READ) do |reg|
reg.each{|name, value, keys | compNameActive = keys}
end
I am getting error messages as "[2015-03-02T09:52:32+00:00] FATAL:
NameError: uninitialized constant Chef::Win32::Registry::KEY_ALL_ACCESS"
Would like to know, do I need to include any other gem?
Thanks & Regards,
Sachin Gupta
On Fri, Feb 27, 2015 at 2:59 AM, Adam Edwards adamed@getchef.com wrote:
Sachin, have you looked at the docs for the registry_key resource:
registry_key Resource,
http://docs.chef.io/release/12-0/dsl_recipe.html#registry-get-values ?
The registry_key_get_values? DSL element seems like a good place to start,
the docs should have examples that clarify the usage.
-Adam
From: Sachin Gupta [mailto:guptasachin1112mrt@gmail.com]
Sent: Thursday, February 26, 2015 10:54 AM
To: chef@lists.opscode.com
Cc: sachin kumar
Subject: [chef] Read windows registry Key values
Hi All,
I am working on a use case where I need to read two registry key values
and compare there data in a recipe
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\ComputerName\ActiveComputerName
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\ComputerName\ComputerName
both are having a value name(ComputerName) and value data(may be same or
different). I need to compare there value data.
Do I need to write like this:; or some other better way??
Win32::Registry::HKEY_LOCAL_MACHINE.open(keynameComp, access) do |reg|
reg.each{|name, value, keys | compName = keys}
end
Win32::Registry::HKEY_LOCAL_MACHINE.open(keynameActive, access) do |reg|
reg.each{|name, value, keys | compNameActive = keys}
end
Any idea??
Thanks & Regards,
Sachin Gupta