Link to home
Start Free TrialLog in
Avatar of ITguy565
ITguy565Flag for United States of America

asked on

Retrieve Version Information from Exe File utilizing WMI

Experts,

I am Attempting to pull Version Information from a EXE file on my Hard Drive and the "ProductVersion" doesn't match the "FileVesion"

An Example of this would be the following command :

$test = get-childitem *fileName*.exe
$test.versioninfo.fileversion = "1.0.0.0"
$test.versioninfo.productversion = "2.3.4.5"

Open in new window

I need to pull the Productversion using nothing but a WMI query..

So far I have found the class cim_datafile which will allow me to pull using the following query

$test2 = get-wmiobject -class cim_datafile -filter "Drive='C:' AND Extension='exe' AND Path Like '%\\programdata\\testr\\%'"|? {$_.name -like "*filename*"}
$test2.version = 1.0.0.0

Open in new window


This means that it is querying the "VersionInfo.FileVersion" Property above


Here is my question is there a way to pull the "ProductVersion" property using nothing but WMI??

I am trying to utilize one of my other toolsets that can only use WMI

Avatar of NVIT
NVIT
Flag of United States of America image

> Here is my question is there a way to pull the "ProductVersion" property using nothing but WMI?? I am trying to utilize one of my other toolsets that can only use WMI

Try this from a cmd prompt. Adjust the filename as needed

wmic datafile where name="C:\\Windows\\System32\\msiexec.exe" get Version /value

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Bill Prew
Bill Prew

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of ITguy565

ASKER

@Bill I was afraid of that.. I had conducted my own research prior to posting this question, but I just needed someone to confirm that was the case. You were right that the Version attribute is the same as the FileVersion property that I showed above in my example.  Thanks for the confirmation!
This is actually very easy to do with a NET API in PowerShell. If you open another question, I'll post the answer there.
@Michael,

Thanks for the offer..  I can pull this information all day long using powershell.

I am trying to use an sysadmin application by the name of Hyena and unfortunately it only gives me the option to use WMI. While I can pull the information I need utilizing the win32_Product class, it is my understanding that this is not best practices as every time this class is initialized it runs a package validation on each of the application on said computer.
Sorry, I first missed the "nothing but a WMI query". But you can do it:
Computername    : ADMIN-DELL
DisplayName     : Microsoft SQL Server Management Studio - 18.9.2
Version         : 15.0.18386.0
Publisher       : Microsoft Corporation
UninstallString : "C:\ProgramData\Package Cache\{e853ab1a-5d1f-434a-9e99-7db61597a575}\SSMS-Setup-ENU.exe"  /uninstall

Open in new window

@Michael,

What WMI class are you using to do that.. I have found two.. The win32_product will pull the "ProductVersion" but it also initiates a  program validation..

The only other WMI class I have found is the "cim_datafile" and it pulls the "Version" not the "productversion" ..

Normally those two values are the same, but in this particular application, the VERSION = 1.0.0.0 and the PRODUCTVERSION = 2.3.4.5
I'm getting it out of the registry.