Skip to content

Commit

Permalink
(GH-2092) Take all registry keys into account
Browse files Browse the repository at this point in the history
It is possible that the installation of an application can generate
multiple registry keys within the snapshot file that is craeted.  Rather
than looking at only the first registry key when deciding if an installed
application is covered by a Chocolatey package, look at all keys within
the snapshot file.
  • Loading branch information
gep13 committed Apr 16, 2021
1 parent 071c9c3 commit f13e946
Showing 1 changed file with 6 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -210,16 +210,14 @@ public virtual IEnumerable<PackageResult> list_run(ChocolateyConfiguration confi

private IEnumerable<PackageResult> report_registry_programs(ChocolateyConfiguration config, IEnumerable<IPackage> list)
{
var itemsToRemoveFromMachine = list.Select(package => _packageInfoService.get_package_information(package)).
Where(p => p.RegistrySnapshot != null).
Select(p => p.RegistrySnapshot.RegistryKeys.FirstOrDefault()).
Where(p => p != null).
Select(p => p.DisplayName).ToList();
var itemsToRemoveFromMachine = list.Select(package => _packageInfoService.get_package_information(package)).Where(p => p.RegistrySnapshot != null).ToList();

var count = 0;
var machineInstalled = _registryService.get_installer_keys().RegistryKeys.
Where((p) => p.is_in_programs_and_features() && !itemsToRemoveFromMachine.Contains(p.DisplayName) && !p.KeyPath.contains("choco-")).
OrderBy((p) => p.DisplayName).Distinct();
var machineInstalled = _registryService.get_installer_keys().RegistryKeys.Where(
p => p.is_in_programs_and_features() &&
!itemsToRemoveFromMachine.Any(pkg => pkg.RegistrySnapshot.RegistryKeys.Any(k => k.DisplayName.is_equal_to(p.DisplayName))) &&
!p.KeyPath.contains("choco-")).OrderBy(p => p.DisplayName).Distinct();

this.Log().Info(() => "");
foreach (var key in machineInstalled)
{
Expand Down

0 comments on commit f13e946

Please sign in to comment.