#!/usr/bin/perl # FileExtP.pl will generate a list of files with incorrect settings for "confirm open after download" # and "always show extension" # Use to determine if these values are set in registry. # File extensions will be loaded from a user supplied file. # 1/18/2009 use strict; use warnings; my $Registry; use Win32::TieRegistry( TiedRef => \$Registry, Delimiter=>"/", SplitMultis => 1, ArrayValues=>1, qw( REG_SZ REG_EXPAND_SZ REG_DWORD REG_BINARY REG_MULTI_SZ KEY_READ ), ); open (my $FI, "fileExtensionList.txt") || die "couldn't open input file"; open (my $FO, "> fileOut.txt") || die "couldn't open output file"; $Registry->Delimiter("/"); # Set delimiter to "/". my $regKey = $Registry->{"Classes/"}; my (@fileExtArr); while (<$FI>) { # get the extensions s/#.*//; # ignore comments next if /^(\s)*$/; # skip blank lines my($Temp)=$_; #Store each line from $FileName to $Temp chomp ($Temp); #strip eol character push @fileExtArr, $Temp; } #testing, only, get all file extensions from HKCR #my @allClassKeys = keys( %{$regKey} ); #@fileExtArr = grep {/^\..*/} @allClassKeys; # foreach(@fileExtArr){ # print "$_\n"; # } my $ctr = 0; foreach(@fileExtArr){ # get value of key each extension points to my $eachSubKey = $regKey->{"$_"} or warn " $_ $^E\n"; if($eachSubKey){ my $keyPtr = $eachSubKey->GetValue("") or warn "$_ $^E\n"; # go to this key for value if($keyPtr){ # check this key for these values if(!$regKey->{$keyPtr}->{"AlwaysShowExt"} || !$regKey->{$keyPtr}->{"EditFlags"}){ $ctr++; print "$ctr $_ $keyPtr\n"; } } } } close($FI); close($FO); exit 0;