3

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"

zabulus
  • 2,373
  • 3
  • 15
  • 27

4 Answers4

5

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.

kenorb
  • 155,785
  • 88
  • 678
  • 743
1

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
Joey
  • 344,408
  • 85
  • 689
  • 683
  • I know about Filever, but it gaves too many information. Could you help me in parsing output of filever? – zabulus Mar 18 '11 at 09:17
  • @zabalus: See edit. I didn't find `filever` for Windows 7 so I couldn't test directly but the code works for the sample output given in the KB article. – Joey Mar 18 '11 at 10:26
1

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.

shanethehat
  • 15,460
  • 11
  • 57
  • 87
0

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

for /F "tokens=3" %%a in ( 'findstr ProductVersion YourProgram.rc' ) do set VERSION=%%~a
Nikolay Raspopov
  • 11
  • 1
  • 1
  • 3