Getting product version from file via cmd/bat

8.1k views Asked by At

I have a file with Version resource that File vesrion/Product version fields are filled. I need to retrieve Product version via BAT file. Example, I have File with ProductVersion 1.0.1 in the output of bat file I wan't to have string "101" or "1.0.1"

4

There are 4 answers

2
Joey On BEST ANSWER

How to use the Filever.exe tool to obtain specific information about a file in Windows

From what I gather about filever's output it's always in columns and you want the fifth column (version). So a simple for should suffice:

for /f "tokens=5 delims= " %%v in ('filever myFile.dll /b') do echo %%v
0
Usman Javaid On

For dummy's like me there is one correction in the above statement to get the value of product version it would be like:

for /f "tokens=5 delims= " %%v in ('filever myFile.dll /b /v') do echo %%v

the /v parameter was missing and I am unable to get the correct value.

0
Nikolay Raspopov On

To read version from resource RC-file you can use:

for /F "tokens=3" %%a in ( 'findstr ProductVersion YourProgram.rc' ) do set VERSION=%%~a
2
kenorb On

You can use sigcheck tool which is part of Sysinternals Suite since filever is quiet old, e.g.

$ sigcheck.exe -q -n app.exe
5.0.0.1241

By specifying -q (quiet) and -n, it'll show you only the file version number.