Why does System.Diagnostics.FileVersionInfo.GetVersionInfo() return unexpected file version information? I’m looking for version information about MPIO drivers. The target OS is Server 2008R2 SP1, which should return FileVersion 6.1.7601. Instead of that, I got 2008R2 RTM version of 6.1.7600.
In addition to incorrect file version, the OriginalFilename is not what I’d expect it to be either. It’s mpio.sys.mui, though FileName is correct.
Correct version information is displayed when examining file’s properties with Explorer.
Is this by design, a bug or am I using FileVersionInfo erroneus a way? Are there any workarounds, preferably on Powershell?
$mpioPath = 'c:\windows\system32\drivers\mpio.sys'
$v = [System.Diagnostics.FileVersionInfo]::GetVersionInfo($mpioPath)
$v | fl -Property *
Comments :
CompanyName : Microsoft Corporation
FileBuildPart : 7601
FileDescription : MultiPath Support Bus-Driver
FileMajorPart : 6
FileMinorPart : 1
FileName : c:\windows\system32\drivers\mpio.sys
FilePrivatePart : 17619
FileVersion : 6.1.7600.16385 (win7_rtm.090713-1255)
InternalName : mpio.sys
IsDebug : False
IsPatched : False
IsPrivateBuild : False
IsPreRelease : False
IsSpecialBuild : False
Language : English (United States)
LegalCopyright : © Microsoft Corporation. All rights reserved.
LegalTrademarks :
OriginalFilename : mpio.sys.mui
PrivateBuild :
ProductBuildPart : 7601
ProductMajorPart : 6
ProductMinorPart : 1
ProductName : Microsoft® Windows® Operating System
ProductPrivatePart : 17619
ProductVersion : 6.1.7600.16385
SpecialBuild :
The same result is achieved with a C# program, so this seems to be more of .Net feature than Powershell specific one.
namespace Foo {
class GetFileVersionInfo {
static void Main(string[] args) {
string mpio = @"c:\windows\system32\drivers\mpio.sys";
System.Diagnostics.FileVersionInfo fvInfo;
fvInfo = System.Diagnostics.FileVersionInfo.GetVersionInfo(mpio);
System.Console.WriteLine("Original file name: " + fvInfo.OriginalFilename);
System.Console.WriteLine("FileVersion: " + fvInfo.FileVersion);
}
}
}
Using FileVer.exe returns correct version info:
filever $mpioPath
--a-- W32 DRV ENU 6.1.7601.17619 shp 156,544 05-20-2011 mpio.sys
I could user FileVer and parse its output, if nothing else works.
I guess FileVer.exe and expolrer.exe doing the same as you can do in powershell: