How do I retrieve the version of a file from a batch file on Windows Vista?

前端 未结 7 1136
傲寒
傲寒 2020-12-05 14:39

Binary files have a version embedded in them - easy to display in Windows Explorer.

\"alt

How can I re

7条回答
  •  生来不讨喜
    2020-12-05 15:35

    I've found this code from Rob Vanderwoude's site:

    @ECHO OFF
    IF [%1]==[] GOTO Syntax
    IF NOT [%2]==[] GOTO Syntax
    ECHO.%1 | FIND "?" >NUL
    IF NOT ERRORLEVEL 1 GOTO Syntax
    IF NOT EXIST %1 GOTO Syntax
    IF NOT "%OS%"=="Windows_NT" GOTO Syntax
    
    SETLOCAL
    SET FileVer=
    FOR /F "tokens=1 delims=[]" %%A IN ('STRINGS %1 ^| FIND /N /V "" ^| FIND /I "FileVersion"') DO SET LineNum=%%A
    SET /A LineNum += 1
    FOR /F "tokens=1* delims=[]" %%A IN ('STRINGS %1 ^| FIND /N /V "" ^| FIND "[%LineNum%]"') DO SET FileVer=%%B
    SET FileVer
    ENDLOCAL
    GOTO:EOF
    
    :Syntax
    ECHO.
    ECHO FileVer.bat,  Version 1.00 for NT 4 / 2000 / XP
    ECHO Display the specified file's version number
    ECHO.
    ECHO Usage:  FILEVER  progfile
    ECHO.
    ECHO Where:  "progfile" is the name of a Windows executable, DLL, or system file
    ECHO.
    ECHO Uses SysInternal's STRINGS.EXE, avalable at http://www.sysinternals.com
    ECHO.
    ECHO Written by Rob van der Woude
    ECHO http://www.robvanderwoude.com
    

    Looks interesting as it uses STRINGS from SysInternals.

提交回复
热议问题