Skip to content
Snippets Groups Projects
Unverified Commit 4e3d5bd4 authored by Oskar Manhart's avatar Oskar Manhart Committed by GitHub
Browse files

fix: catch error if exe has no version info

parent 95daa5d8
No related branches found
No related tags found
No related merge requests found
...@@ -103,11 +103,9 @@ function GetApplicationName { ...@@ -103,11 +103,9 @@ function GetApplicationName {
[string]$exePath [string]$exePath
) )
if ((Get-Item $exePath).VersionInfo.FileDescription) { try {
# Remove leading/trailing whitespace and replace multiple spaces with a single space.
$productName = (Get-Item $exePath).VersionInfo.FileDescription.Trim() -replace '\s+', ' ' $productName = (Get-Item $exePath).VersionInfo.FileDescription.Trim() -replace '\s+', ' '
} else { } catch {
# Get the executable file name without the file extension.
$productName = [System.IO.Path]::GetFileNameWithoutExtension($exePath) $productName = [System.IO.Path]::GetFileNameWithoutExtension($exePath)
} }
...@@ -125,10 +123,7 @@ function GetUWPApplicationName { ...@@ -125,10 +123,7 @@ function GetUWPApplicationName {
# Query the application executable for the application name. # Query the application executable for the application name.
if (Test-Path $exePath) { if (Test-Path $exePath) {
if ((Get-Item $exePath).VersionInfo.FileDescription) { $productName = GetApplicationName -exePath $exePath
# Remove leading/trailing whitespace and replace multiple spaces with a single space.
$productName = (Get-Item $exePath).VersionInfo.FileDescription.Trim() -replace '\s+', ' '
}
} }
# Use the 'DisplayName' (if available) if the previous method failed. # Use the 'DisplayName' (if available) if the previous method failed.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment