Skip to content

Commit

Permalink
Merge pull request #1638 from chef/backports
Browse files Browse the repository at this point in the history
Update `packages` for Windows to be complete.
  • Loading branch information
tas50 authored Apr 2, 2021
2 parents 86dc646 + a515464 commit 88610e7
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions lib/ohai/plugins/packages.rb
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@
end
end

def collect_programs_from_registry_key(key_path)
def collect_programs_from_registry_key(repo, key_path)
# from http://msdn.microsoft.com/en-us/library/windows/desktop/aa384129(v=vs.85).aspx
if ::RbConfig::CONFIG["target_cpu"] == "i386"
reg_type = Win32::Registry::KEY_READ | 0x100
Expand All @@ -115,7 +115,7 @@ def collect_programs_from_registry_key(key_path)
else
reg_type = Win32::Registry::KEY_READ
end
Win32::Registry::HKEY_LOCAL_MACHINE.open(key_path, reg_type) do |reg|
repo.open(key_path, reg_type) do |reg|
reg.each_key do |key, _wtime|
pkg = reg.open(key)
name = pkg["DisplayName"] rescue nil
Expand All @@ -133,9 +133,10 @@ def collect_programs_from_registry_key(key_path)
collect_data(:windows) do
require "win32/registry" unless defined?(Win32::Registry)
packages Mash.new
collect_programs_from_registry_key('Software\Microsoft\Windows\CurrentVersion\Uninstall')
collect_programs_from_registry_key(Win32::Registry::HKEY_LOCAL_MACHINE, 'Software\Microsoft\Windows\CurrentVersion\Uninstall')
collect_programs_from_registry_key(Win32::Registry::HKEY_CURRENT_USER, 'Software\Microsoft\Windows\CurrentVersion\Uninstall')
collect_programs_from_registry_key(Win32::Registry::HKEY_LOCAL_MACHINE, 'Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall')
# on 64 bit systems, 32 bit programs are stored here
collect_programs_from_registry_key('Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall')
end

collect_data(:aix) do
Expand Down

0 comments on commit 88610e7

Please sign in to comment.