How do grab the file version/product version from a file on the Windows 7 command line, to be used in a variable in a .bat file?

  • 1
    Are you referring to actual DOS, or the Windows command line? In any case, please state the OS version you're working with. – Daniel Beck Jan 13 '12 at 20:51
  • Windows command line – jaekie Jan 13 '12 at 20:55
  • What kind of file? How is the version information stored or accessed? – Keith Thompson Jan 13 '12 at 20:55
  • 1
    What version of Windows? There have been some changes between '95 and 7. – Daniel Beck Jan 13 '12 at 20:56
  • 1
    Found this for you: stackoverflow.com/questions/602802/… – billc.cn Jan 13 '12 at 21:08

From my understanding you need filever.exe to do this. As pointed out in the comments. Also, I ripped the below word for word from here

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
  • This worked for me, except I used a vbscript to get the file version, but led me in right direction – jaekie Jan 14 '12 at 18:25
  • 1
    That second link no longer works, just FYI. – Broots Waymb Apr 19 '18 at 16:01

You can check using sigcheck.exe which is part of Sysinternals Suite, e.g.

$ sigcheck.exe -q -n app.exe

By specifying -q (quiet, no banner) and -n will show you only the file version number, so you can assign it into the variable.

If you're using Sigcheck64, the 64bit version provided for Nano Server, which doesn't support 32bit programs, the -q parameter has been replaced by -nobanner. E.g.

$ sigcheck.exe -nobanner -n app.exe

Source: What is the difference between Sigcheck and Sigcheck64? and SigCheck manual page.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.