Home > Software design >  How to get Display Name from an installer file in powershell
How to get Display Name from an installer file in powershell

Time:10-18

I'm trying to install a software in my computer using Powershell script.

Before install, I want to check if my installer file version is newer than the installed program.

For the installed program I can get the DisplayName, Version, etc...

but I need to get the DisplayName of the installer file before to make some queries with this DisplayName.

For instance

I have installed npp.7.9.5.Installer.x64 (Version 7.9.5) and

I want to install npp.8.1.7.Installer.x64 (Version 8.1.7)

I can get version and name with this, (for the installed programs in my computer).

Get-WmiObject -Class Win32_Product | select Name, Version 

But I want to know if I can get the same info from my npp.8.1.7.Installer.x64.exe file, (something like extract info from the installer)

CodePudding user response:

The developers of Notepad seem to do a good job. They do put the proper version number to the installer file. So you can easily get the information with PowerShell by getting the properties of the installer file like this:

$NPPInstallerFile = Get-Item -Path 'D:\olaf\Downloads\npp.8.1.7.Installer.x64.exe'
$NPPInstallerFile.VersionInfo.FileVersion
$NPPInstallerFile.VersionInfo.ProductVersion

That provides an output like this:

8.1.7.0
8.17

CodePudding user response:

In addition to Olaf's answer you can do

$NPPInstallerFile = Get-Item -Path 'D:\Downloads\npp.8.1.7.Installer.x64.exe'
$NPPInstallerFile.VersionInfo | Format-List *

To see all info of the version like:

FileVersionRaw     : 8.1.7.0
ProductVersionRaw  : 8.1.7.0
Comments           : 
CompanyName        : Don HO [email protected]
FileBuildPart      : 7
FileDescription    : Notepad   : a free (GNU) source code editor
FileMajorPart      : 8
FileMinorPart      : 1
FileName           : D:\Downloads\npp.8.1.7.Installer.x64.exe
FilePrivatePart    : 0
FileVersion        : 8.1.7.0
InternalName       : 
IsDebug            : False
IsPatched          : False
IsPrivateBuild     : False
IsPreRelease       : False
IsSpecialBuild     : False
Language           : Engels (Verenigde Staten)
LegalCopyright     : Copyleft 1998-2017 by Don HO
LegalTrademarks    : 
OriginalFilename   : 
PrivateBuild       : 
ProductBuildPart   : 7
ProductMajorPart   : 8
ProductMinorPart   : 1
ProductName        : Notepad  
ProductPrivatePart : 0
ProductVersion     : 8.17
SpecialBuild       :

There is no DisplayName property.. Perhaps you want the FileDescription or ProductName ?

  • Related