MSI info lister plugin with AnyCmd

Discuss and announce Total Commander plugins, addons and other useful tools here, both their usage and their development.

Moderators: white, Hacker, petermad, Stefan2

Post Reply
User avatar
ZoSTeR
Power Member
Power Member
Posts: 1008
Joined: 2004-07-29, 11:00 UTC

MSI info lister plugin with AnyCmd

Post by *ZoSTeR »

The windows explorer details for MSI files are very limited. They are missing e.g. the exact product name and version.

To get a more detailed view you can use a PowerShell script with AnyCMD

Create a copy of the AnyCmd plugin folder as "Plugins\wlx\anycmd_MSI" with this AnyCmd.ini

AnyCmd.ini

Code: Select all

[AnyCmd]
command=powershell.exe -NoLogo -NoProfile -NonInteractive -Command "& {& "$env:COMMANDER_PATH\Plugins\wlx\anycmd_MSI\Get-MSI-Info.ps1" -MsiPath '%s'}"
DetectString=EXT=MSI
Stream=3
Put the script "Get-MSI-Info.ps1" inside the anycmd_MSI folder.

Get-MSI-Info.ps1

Code: Select all

param (
    [parameter(Mandatory=$true)] 
    [ValidateNotNullOrEmpty()] 
    [System.IO.FileInfo] $MsiPath
)

# Remove or reorder the properties for desired summary info output:

$summaryInfoProperties = [ordered]@{
    "Title" = 2
    "Subject" = 3
    "Author" = 4
    "Keywords" = 5
    "Comments" = 6
    "Template" = 7
    "Codepage" = 1
    "Last Saved By" = 8
    "Revision Number" = 9
    "Last Printed" = 11
    "Create Time/Date" = 12
    "Last Save Time/Date" = 13
    "Page Count" = 14
    "Word Count" = 15
    "Character Count" = 16
    "Creating Application" = 18
    "Security" = 19
}

if (!(Test-Path $MsiPath.FullName)) { 
    throw "File '{0}' does not exist" -f $MsiPath.FullName 
}

try { 
    $windowsInstaller = New-Object -ComObject WindowsInstaller.Installer 
    $database = $windowsInstaller.OpenDatabase($MsiPath.FullName, 0)

    #Get the SummaryInfo
    $info = $database.SummaryInformation(0)
    $tmpSummaryInfo = [ordered]@{}
    foreach ($summaryInfoProperty in $summaryInfoProperties.GetEnumerator())
    {
        $tmpSummaryInfo[$summaryInfoProperty.Name] = $info.Property($summaryInfoProperty.Value)
    }
    Write-Output ($tmpSummaryInfo | Format-Table -HideTableHeaders)

    #Get the MSI properties
    $query = "SELECT Property, Value FROM Property"
    $view = $database.OpenView($query)
    $view.Execute()
    $tmpProperties = [ordered]@{}
    while (($record = $view.Fetch()) -ne $null)
    {
        $tmpProperties[$record.StringData(1)] = $record.StringData(2)
    }
    Write-Output ($tmpProperties | Format-Table -HideTableHeaders)
} catch { 
    throw "Failed to get MSI file info: {0}." -f $_
} 
Double click on the "anycmd_MSI\anycmd.wlx" file to register it.
Restart TC and you're set.


Here is the sample output from an MS Edge Browser MSI:

Code: Select all

Title                          Installation Database                                                                   
Subject                        Microsoft Edge Installer                                                                
Author                         Microsoft Corporation                                                                   
Keywords                       Installer                                                                               
Comments                       101.0.1210.39 Copyright 2022 Microsoft Corporation                                      
Template                       Intel;1033                                                                              
Codepage                       1252                                                                                    
Last Saved By                                                                                                          
Revision Number                {08163D64-02A2-49A5-8126-B4AC63BFA3D1}                                                  
Last Printed                                                                                                           
Create Time/Date               05.05.2022 10:10:48                                                                     
Last Save Time/Date            05.05.2022 10:10:48                                                                     
Page Count                     150                                                                                     
Word Count                     2                                                                                       
Character Count                                                                                                        
Creating Application           Windows Installer XML Toolset (3.11.1.2318)                                             
Security                       2                                                                                       



UpgradeCode                    {883C2625-37F7-357F-A0F4-DFAF391B2B9C}                                                  
ALLOWINSTALL                   0                                                                                       
RS3PRODUCTNAME                 0                                                                                       
AllowDowngradeSubstitution     false                                                                                   
ALLUSERS                       1                                                                                       
DONOTCREATEDESKTOPSHORTCUT     false                                                                                   
DONOTCREATETASKBARSHORTCUT     false                                                                                   
ARPPRODUCTICON                 icon.ico                                                                                
ARPNOMODIFY                    1                                                                                       
Manufacturer                   Microsoft Corporation                                                                   
ProductCode                    {64EC03E5-8764-3FE8-9BCE-3B00856BF586}                                                  
ProductLanguage                1033                                                                                    
ProductName                    Microsoft Edge                                                                          
ProductVersion                 101.0.1210.39                                                                           
SecureCustomProperties         NEWPRODUCTFOUND;UPGRADEFOUND                                                            

Here's a trimmed down version which i use:

Code: Select all

param (
    [parameter(Mandatory=$true)] 
    [ValidateNotNullOrEmpty()] 
    [System.IO.FileInfo] $MsiPath
)

# Remove or reorder the properties for desired summary info output:

$summaryInfoProperties = [ordered]@{
    "Subject" = 3
    "Author" = 4
    "Keywords" = 5
    "Comments" = 6
    "Revision Number" = 9
    "Create Time/Date" = 12
    "Last Save Time/Date" = 13
    "Creating Application" = 18
}

if (!(Test-Path $MsiPath.FullName)) { 
    throw "File '{0}' does not exist" -f $MsiPath.FullName 
}

try { 
    $windowsInstaller = New-Object -ComObject WindowsInstaller.Installer 
    $database = $windowsInstaller.OpenDatabase($MsiPath.FullName, 0)

    #Get the SummaryInfo
    $info = $database.SummaryInformation(0)
    $tmpSummaryInfo = [ordered]@{}
    foreach ($summaryInfoProperty in $summaryInfoProperties.GetEnumerator())
    {
        $tmpSummaryInfo[$summaryInfoProperty.Name] = $info.Property($summaryInfoProperty.Value)
    }

    #Get the MSI properties
    $query = "SELECT Property, Value FROM Property"
    $view = $database.OpenView($query)
    $view.Execute()
    $tmpProperties = [ordered]@{}
    while (($record = $view.Fetch()) -ne $null)
    {
        $tmpProperties[$record.StringData(1)] = $record.StringData(2)
    }
    Write-Output ""
    Write-Output ("ProductName                    {0}" -f $tmpProperties.ProductName)
    Write-Output ("ProductVersion                 {0}" -f $tmpProperties.ProductVersion)
    Write-Output ("Manufacturer                   {0}" -f $tmpProperties.Manufacturer)
    Write-Output ("Info URL                       {0}" -f $tmpProperties.ARPURLINFOABOUT)
    Write-Output ("ProductLanguage                {0}" -f $tmpProperties.ProductLanguage)
    Write-Output ("ProductCode                    {0}" -f $tmpProperties.ProductCode)
    Write-Output ("UpgradeCode                    {0}" -f $tmpProperties.UpgradeCode)
    Write-Output ($tmpSummaryInfo | Format-Table -HideTableHeaders)
} catch { 
    throw "Failed to get MSI file info: {0}." -f $_
}
Post Reply