Below is a more or less literal translation of the VBS code linked to in the OP (identical subroutine structure; similar variable names).

That code does the right thing on 2 WinXP machines with messaging installed. But I learnt during testing that the path to follow to get the PST names was different on both, so I assume there are different versions of Windows Messaging involved here, and probably there are even more variants where the code will fail ;-).

use strict; use warnings; use Win32::TieRegistry (Delimiter => '/'); use Encode; use Data::Dumper; my %r = ( PSTGuidLocation => '01023d00', MasterConfig => '01023d0e', PSTCheckFile => '00033009', PSTFile => '001f6700', PSTFile1 => '001e6700', keyMaster => '9207f3e0a3b11019908b08002b2a56c2', ProfilesRoot => 'CUser/Software/Microsoft/Windows NT/CurrentVersion/ +Windows Messaging Subsystem/Profiles/', DefaultProfileString => '/DefaultProfile', ); my $MessagingRoot = $Registry->{$r{ProfilesRoot}} # points to the Prof +iles reg path of the current user or die "Windows Messaging not installed here!?\n"; my $DefaultProfileName = $MessagingRoot->{$r{DefaultProfileString}} or die "There are no messaging profiles for this user on this machin +e.\n"; my %Out = ("DefaultProfile" => $DefaultProfileName, Profiles => {}); my @Profiles = grep {s/\/$//} keys %{$MessagingRoot}; for my $profileName (@Profiles) { $Out{Profiles}{$profileName} = [ GetPSTsForProfile($profileName) ]; } print Dumper(\%Out); sub GetPSTsForProfile { my $profileName = shift; my $regProfile = $MessagingRoot->{"$profileName/"}; my $strValue = $MessagingRoot->{"$profileName/$r{keyMaster}//$r{Mast +erConfig}"}; my $fmt = '%02x' x 16; my @PSTFileNames; for my $strPSTGuid (map {sprintf $fmt, unpack('C16', $_)} $strValue +=~ /.{16}/g) { my $PSTGuid2 = PSTlocation($regProfile->{"$strPSTGuid/"}) or next; push @PSTFileNames, PSTFileName($regProfile->{$PSTGuid2}) if IsAPST($regProfile->{"$strPSTGuid/"}); } return @PSTFileNames; } sub IsAPST { my $PSTGuid = shift or return; my $PSTGuildValue = $PSTGuid->{"/$r{PSTCheckFile}"} or return; unpack('L', $PSTGuildValue) == 0x20; } sub PSTlocation { my $PSTGuid = shift or return; my $PSTGuildValue = $PSTGuid->{"/$r{PSTGuidLocation}"} or return; my $len = length($PSTGuildValue); my @PSTGuildValue = unpack("C$len",$PSTGuildValue); my $fmt = '%02x' x $len; sprintf($fmt, @PSTGuildValue); } sub PSTFileName { my $PSTGuid = shift or return; my $PSTName = $PSTGuid->{$r{PSTFile}}; defined $PSTName ? decode('UCS2-LE', $PSTName) : $PSTGuid->{$r{PSTFi +le1}}; }

In reply to Re: Easy way to get the location of Outlook PSTs into my perl script? by pKai
in thread Easy way to get the location of Outlook PSTs into my perl script? by rsilvergun

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.