$path = "MSDE2000A"; $info = [System.Diagnostics.FileVersionInfo]::GetVersionInfo($path);
以下是它正在抛出的异常信息:
Exception calling "GetVersionInfo" with "1" argument(s): "MSDE2000A.exe" At line:1 char:58 + $f = [system.diagnostics.fileversioninfo]::getversioninfo <<<< ("MSDE2000A.exe") + CategoryInfo : NotSpecified: (:) [], MethodInvocationException + FullyQualifiedErrorId : DotNetMethodException
我检查过的每个文件都有相同的结果。但是,如果我的路径是c:\windows\notepad.exe(如 example )它按预期工作。发生什么事?
[Diagnostics.FileVersionInfo]::GetVersionInfo('C:\Windows\System32\user32.dll') ProductVersion FileVersion FileName -------------- ----------- -------- 6.1.7600.16385 6.1.7600.1638... C:\Windows\System32\user32.dll
此外,您还可以使用get ChildItem获得此信息,例如:
Get-ChildItem C:\Windows\System32\user32.dll | fl VersionInfo