diff --git a/install/ExtractPrograms.ps1 b/install/ExtractPrograms.ps1 index b1587ea..3357f15 100644 --- a/install/ExtractPrograms.ps1 +++ b/install/ExtractPrograms.ps1 @@ -103,11 +103,9 @@ function GetApplicationName { [string]$exePath ) - if ((Get-Item $exePath).VersionInfo.FileDescription) { - # Remove leading/trailing whitespace and replace multiple spaces with a single space. + try { $productName = (Get-Item $exePath).VersionInfo.FileDescription.Trim() -replace '\s+', ' ' - } else { - # Get the executable file name without the file extension. + } catch { $productName = [System.IO.Path]::GetFileNameWithoutExtension($exePath) } @@ -125,10 +123,7 @@ function GetUWPApplicationName { # Query the application executable for the application name. if (Test-Path $exePath) { - if ((Get-Item $exePath).VersionInfo.FileDescription) { - # Remove leading/trailing whitespace and replace multiple spaces with a single space. - $productName = (Get-Item $exePath).VersionInfo.FileDescription.Trim() -replace '\s+', ' ' - } + $productName = GetApplicationName -exePath $exePath } # Use the 'DisplayName' (if available) if the previous method failed.