Windows: Command line to read version info of an executable file?

前端 未结 7 676
隐瞒了意图╮
隐瞒了意图╮ 2020-12-14 02:23

Does Windows have an executable that I can run in the command shell which returns the version number of an executable (.exe) file?

I see a lot of questions that sho

7条回答
  •  攒了一身酷
    2020-12-14 03:21

    If you are willing and able to use PowerShell, the following code will work. If you are on a supported Windows system, PowerShell will be available.

    (Get-Item -Path 'C:\Program Files\Java\jdk1.8.0_144\bin\java.exe').VersionInfo |
        Format-List -Force
    

    If you must run it in a cmd.exe shell, you could use:

    powershell -NoLogo -NoProfile -Command ^
        "(Get-Item -Path 'C:\Program Files (x86)\Java\jre1.8.0_201\bin\java.exe').VersionInfo |" ^
            "Format-List -Force"
    

提交回复
热议问题