This is the Perl Code that I'm using. Hope it will help others that are looking for the same...
[CODE]
#!perl
use Win32::OLE;
use strict;
use constant msiOpenDatabaseModeReadOnly => 0;
use constant msiOpenDatabaseModeTransact => 1;
my ($param, $argCount, $file);
$argCount = @ARGV;
if (($argCount < 1)) {
print "\n\t#############################################################
Windows Installer utility to execute SQL queries against an installer database.
This returns the Product Name, Product code, and Upgrade code of all MSI files
given in the path or the file specified on the command line.
The 1st argument specified can be the path to search or the file you want info from.
\n\tExample: MSI_Properties.pl \"\\path\\share\\\" or \"\\path\\share\\msifile.msi\"\n
\t#############################################################
";
exit (1);
}
my $openMode = msiOpenDatabaseModeReadOnly;
# Connect to Windows installer object
my $installer = undef;
$installer = Win32::OLE->new('WindowsInstaller.Installer');
CheckError();
$param = $ARGV[0];
if ($param =~/(\.msi)/ || (-d $param)){
$file = $1;
}else{
die "Need MSI file or directory!\n";
}
my (@msis, $cmd);
# Open database
my $databasePath = $ARGV[0]."\\*.msi";
if ($file){
@msis = ($ARGV[0]);
}else{
$cmd = "dir \"$databasePath\" /b /s";
print "$cmd\n";
@msis = qx($cmd);
}
my ($ctr, %msiData);
my $output = "MSI-Value";
&Name;
$output = $output.".xls";
open OUT, ">$output";
print OUT "Product Name\tUpgrade Code\tProduct Code\tFile - Path\n"; #header row
for (@msis){
chomp;
$ctr++;
my $database = $installer->OpenDatabase($_, $openMode);
CheckError();
my ($value, $query, $view, $record, $message, $rowData, $columnCount, $delim, $column);
my @query_value = qw(ProductName UpgradeCode ProductCode);
foreach $value(@query_value){
$message;
$query = "SELECT \`Value\` FROM \`Property\` WHERE \`Property\`=\'$value\'";
$view = $database->OpenView($query);
CheckError();
$view->Execute();
CheckError();
if (uc(substr($query, 0, 6)) eq 'SELECT') {
while (1) {
$record = $view->Fetch;
last if !($record->{FieldCount});
$columnCount = $record->FieldCount;
$rowData = "";
$delim = ' ';
for my $column (1 .. $columnCount) {
if ($column eq $columnCount) {
#$delim = vbLf;
}
$rowData = $rowData . $record->StringData($column) . $delim;
}
$message = $rowData;
chomp $message;
$msiData{$ctr}{$value} = $message;
}
}
$msiData{$ctr}{'PATH'} = $_;
if (defined($message)) {
print "$msiData{$ctr}{$value}\n";
print OUT "$msiData{$ctr}{$value}\t";
}
}
print OUT "$msiData{$ctr}{'PATH'}";
print "\n";
print OUT "\n";
$database->Close();
}
print "$ctr records added to $output\n";
close OUT;
exit (0);
sub CheckError {
my ($message, $errRec);
return if (0 + Win32::OLE::LastError()) == 0;
$message = ' ' . sprintf("%x", (0 + Win32::OLE::LastError())) . ': ' . ('' . Win32::OLE::LastError());
if (!($installer)) {
$errRec = $installer->LastErrorRecord;
if (!($errRec)) {
$message = $message . $errRec->FormatText;
}
}
Fail($message);
}
sub Fail {
my($message) = @_;
print "$message";
exit (2);
}
sub Name {
if (-e "$output.xls"){
my ($p1, $nctr) = split(/_/, $output);
$nctr++;
$output = join("_", $p1, $nctr);
&Name;
}else{
return;
}
}
[/CODE]
This will take a path or .msi file and return the Product name, Upgrade code, and Product Code from the msi. If it's a path, then it will run on all of them within the folder you specify. It dumps this out to a file called msi-values.xls (tab delimited). This file will increment as if it's already there...
Good luck and thanks for the help.