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: Hacker, petermad, Stefan2, white

Post Reply
User avatar
ZoSTeR
Power Member
Power Member
Posts: 1049
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 $_
}
*Edit: Added some double quotes
Last edited by ZoSTeR on 2025-01-29, 15:46 UTC, edited 2 times in total.
User avatar
Wawuschel
Senior Member
Senior Member
Posts: 344
Joined: 2003-02-11, 17:00 UTC

MSI info lister plugin with AnyCmd

Post by *Wawuschel »

Hi,

Many thanks for your instructions

I get an error message wen I use a path with a space use.

Code: Select all

C:\TotalCommander\Plugins\WLX - ListerPlugin\AnyCmd_MSI\Get-MSI-Info.ps1

Code: Select all

& : Die Benennung "C:\TotalCommander\Plugins\WLX" wurde nicht als Name eines Cmdlet, einer Funktion, einer Skriptdatei 
oder eines ausfhrbaren Programms erkannt. šberprfen Sie die Schreibweise des Namens, oder ob der Pfad korrekt ist 
(sofern enthalten), und wiederholen Sie den Vorgang.
In Zeile:1 Zeichen:6
+ & {& $env:COMMANDER_PATH\Plugins\WLX - ListerPlugin\AnyCmd_MSI\Get-MS ...
+      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (C:\TotalCommander\Plugins\WLX:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException
 
How can I resolve the problem?

Thanks.
TCmd 11.50b8 (64 bit) unter Windows 11 (64 bit)
#76996
User avatar
norfie²
Power Member
Power Member
Posts: 1038
Joined: 2006-02-10, 07:27 UTC

Re: MSI info lister plugin with AnyCmd

Post by *norfie² »

2Wawuschel
Don't use space characters in the path and filename. :mrgreen:
"War is evil, in so far as it makes more bad people than it takes away."
Immanuel Kant in "Perpetual Peace"
User avatar
ZoSTeR
Power Member
Power Member
Posts: 1049
Joined: 2004-07-29, 11:00 UTC

Re: MSI info lister plugin with AnyCmd

Post by *ZoSTeR »

 
You have to use triple double qoutes ;)

Code: Select all

[AnyCmd]
command=powershell.exe -NoLogo -NoProfile -NonInteractive -Command "& {& """$env:COMMANDER_PATH\Plugins\wlx\anycmd MSI with Spaces\Get-MSI-Info.ps1""" -MsiPath '%s'}"
DetectString=EXT=MSI
Stream=3
Backtick double quotes didn't work for some reason and single quotes don't work because there's a variable in the string.
Escaping in PowerShell can become a hassle sometimes.
mihail_ms
Junior Member
Junior Member
Posts: 24
Joined: 2024-06-01, 00:00 UTC

Re: MSI info lister plugin with AnyCmd

Post by *mihail_ms »

Anycmd does not support Cyrillic alphabet in the path.
Spoiler
Anycmd не поддерживает кириллицу в путь.
Post Reply