May 29th, 2018

How do I get file version information from the command line?

The great thing about Windows file versions is that there are so many to choose from!

For each file, you have

  • Numeric product version
  • Numeric file version
  • String product version
  • String file version

The numeric and string versions generally match, but there is no enforcement. Often the string version incorporates the numeric version but adds some additional information, like 3.1.0.2 (alpha). Sometimes the string version disagrees with the numeric version. This can happen when MUI satellite DLLs enter the picture.

You can use PowerShell to obtain the version information for a file.

PS> (Get-Command C:\Path\To\Thing.dll).FileVersionInfo.FileVersion
3.1.0.2

The version number parts of the File­Version­Info are

Product Field File Field Meaning Example
ProductVersion FileVersion String version 3.1.0.2 (alpha)
ProductMajorPart FileMajorPart First number 3
ProductMinorPart FileMinorPart Second number 1
ProductBuildPart FileBuildPart Third number 0
ProductPrivatePart FilePrivatePart Fourth number 2

Further reading: How to (correctly) check file versions with PowerShell.

Author

Raymond has been involved in the evolution of Windows for more than 30 years. In 2003, he began a Web site known as The Old New Thing which has grown in popularity far beyond his wildest imagination, a development which still gives him the heebie-jeebies. The Web site spawned a book, coincidentally also titled The Old New Thing (Addison Wesley 2007). He occasionally appears on the Windows Dev Docs Twitter account to tell stories which convey no useful information.

0 comments

Discussion are closed.