forked from timops/ohai-plugins
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwin32_software.rb
More file actions
30 lines (27 loc) · 1.72 KB
/
win32_software.rb
File metadata and controls
30 lines (27 loc) · 1.72 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
provides 'installed_software'
installed_software Mash.new
reg_type = Win32::Registry::KEY_READ | 0x100
Win32::Registry::HKEY_LOCAL_MACHINE.open('SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall', reg_type ) do |reg|
reg.each_key do |key|
k = reg.open(key)
installed_software[(k["DisplayName"] rescue "?")] = Mash.new
installed_software[(k["DisplayName"] rescue "?")]['DisplayVersion'] = k["DisplayVersion"] rescue "?"
installed_software[(k["DisplayName"] rescue "?")]['Version'] = k["Version"] rescue "?"
installed_software[(k["DisplayName"] rescue "?")]['Publisher'] = k["Publisher"] rescue "?"
installed_software[(k["DisplayName"] rescue "?")]['InstallDate'] = k["InstallDate"] rescue "?"
installed_software[(k["DisplayName"] rescue "?")]['InstallLocation'] = k["InstallLocation"] rescue "?"
installed_software[(k["DisplayName"] rescue "?")]['URLInfoAbout'] = k["URLInfoAbout"] rescue "?"
end
end
Win32::Registry::HKEY_LOCAL_MACHINE.open('SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall' ) do |reg|
reg.each_key do |key|
k = reg.open(key)
installed_software[(k["DisplayName"] rescue "?")] = Mash.new
installed_software[(k["DisplayName"] rescue "?")]['DisplayVersion'] = k["DisplayVersion"] rescue "?"
installed_software[(k["DisplayName"] rescue "?")]['Version'] = k["Version"] rescue "?"
installed_software[(k["DisplayName"] rescue "?")]['Publisher'] = k["Publisher"] rescue "?"
installed_software[(k["DisplayName"] rescue "?")]['InstallDate'] = k["InstallDate"] rescue "?"
installed_software[(k["DisplayName"] rescue "?")]['InstallLocation'] = k["InstallLocation"] rescue "?"
installed_software[(k["DisplayName"] rescue "?")]['URLInfoAbout'] = k["URLInfoAbout"] rescue "?"
end
end