summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--chef-x86-mingw32.gemspec1
-rw-r--r--lib/chef/win32/wmi.rb12
2 files changed, 9 insertions, 4 deletions
diff --git a/chef-x86-mingw32.gemspec b/chef-x86-mingw32.gemspec
index 49a15bcf00..819c7eddbb 100644
--- a/chef-x86-mingw32.gemspec
+++ b/chef-x86-mingw32.gemspec
@@ -4,7 +4,6 @@ gemspec = eval(IO.read(File.expand_path("../chef.gemspec", __FILE__)))
gemspec.platform = "x86-mingw32"
gemspec.add_dependency "ffi", "1.5.0"
-gemspec.add_dependency "rdp-ruby-wmi", "0.3.1"
gemspec.add_dependency "windows-api", "0.4.2"
gemspec.add_dependency "windows-pr", "1.2.2"
gemspec.add_dependency "win32-api", "1.5.1"
diff --git a/lib/chef/win32/wmi.rb b/lib/chef/win32/wmi.rb
index c3d6cf7d3b..9ed02c6aea 100644
--- a/lib/chef/win32/wmi.rb
+++ b/lib/chef/win32/wmi.rb
@@ -16,6 +16,7 @@
# limitations under the License.
#
+require 'win32ole'
require 'chef/reserved_names'
class Chef
@@ -45,7 +46,12 @@ class Chef
def first_of(wmi_class)
query_result = start_query("select * from #{wmi_class}")
- wmi_result_to_snapshot(query_result.first)
+ first_result = nil
+ query_result.each do | record |
+ first_result = record
+ break
+ end
+ first_result.nil? ? nil : wmi_result_to_snapshot(first_result)
end
private
@@ -55,14 +61,14 @@ class Chef
end
def new_connection(namespace)
- locator = WIN32OLE.new("WbemScripting.SWbemLocator")
+ locator = ::WIN32OLE.new("WbemScripting.SWbemLocator")
locator.ConnectServer('.', namespace)
end
def wmi_result_to_hash(wmi_object)
property_map = {}
wmi_object.properties_.each do |property|
- property_map[property.name.downcase] = wmi_object.send(property.name)
+ property_map[property.name.downcase] = wmi_object.invoke(property.name)
end
property_map[:wmi_object] = wmi_object