代码之家  ›  专栏  ›  技术社区  ›  scottm

GetVersionInfo和powershell的参数异常

  •  1
  • scottm  · 技术社区  · 16 年前

    $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 )它按预期工作。发生什么事?

    1 回复  |  直到 16 年前
        1
  •  7
  •   Keith Hill    16 年前

    [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
    
    推荐文章