November 2010 Archives

Listing All Installed Programs in Windows XP

I wanted to get a list of all the programs installed on my computer listed in 'Add or Remove Programs' in the Control Panel in Windows XP. Win32::TieRegistry provided a nice way to do this.

#!perl
use warnings;
use strict;
use Data::Dumper;

my $Registry;

use Win32::TieRegistry (
  Delimiter   => "/",
  ArrayValues => 1,
  TiedRef     => \$Registry,
 );

my $regkey = 'HKEY_LOCAL_MACHINE/Software/Microsoft/Windows/CurrentVersion/Uninstall/';

my @install_names;
foreach my $software ( values %{$Registry->{$regkey}} ) {
  next unless my $software = $software->{DisplayName};
  next unless $software->[0];
  push @install_names, $software->[0];
}

print "$_\n" for sort {lc $a cmp lc $b} @install_names;

Win32::TieRegistry installs along with Strawberry Perl.

About initself

user-pic Perl is better than sliced bread. Way better.