6

Possible Duplicates:
Command line tool to dump Windows DLL version?
How do I retrieve the version of a file from a batch file on Windows Vista?

Is it possible to get the file version of a dll or exe file using batch commands and store it in a variable?

Community
  • 1
  • 1
Calumet
  • 73
  • 1
  • 1
  • 4

2 Answers2

11

Here's an example using sigcheck:

@ECHO OFF

FOR /F "tokens=1-3" %%i IN ('p:\supporttools\sigcheck.exe p:\supporttools\procmon.exe') DO ( IF "%%i %%j"=="File version:" SET filever=%%k )

ECHO The version of the file is %filever%

PAUSE
Dave
  • 1,062
  • 7
  • 8
  • Better to use sigcheck then filever. You can easily bundle either little utility with your project to ensure it's available, and both run on XP and up, but filever has a .net dependency. Also, the -n switch in sigcheck is very helpful, I'm not sure if filever has an equivalent. – BuvinJ Apr 28 '15 at 15:58
10

Have a look at the Sysinternals utility SigCheck. Try this in your batch script:

sigcheck.exe -n YourFile.exe
serk
  • 4,329
  • 2
  • 25
  • 38
  • Thanks. Both SigCheck and Filever dump the file version. I am trying to set a variable in the batch file to the file version. I can't figure that part out. – Calumet Jul 14 '11 at 18:27
  • http://stackoverflow.com/questions/1746475/dos-windows-batch-help-in-setting-a-variable-from-command-output – Mike Atlas Jul 14 '11 at 18:39
  • @Calumet What have you tried so far? – serk Jul 14 '11 at 18:44