The Windows 2000 Support Tools, and the Windows XP Support Tools, contain Filever.exe,
which will return the version of a file. If you type filever %SystemRoot%\notepad.exe on Windows 2000, you receive:

----- W32i APP ENU 5.0.2140.1 shp 50,960 12-07-1999 notepad.exe and version 5.1.2600.0 on Windows XP.

I have scripted FileVersion.bat to return the Version environment variable. The syntax is:

FileVersion Fully_Qualified_FileName


FileVersion %windir%\notepad.exe sets the Version environment variable to 5.0.2140.1 on Windows 2000.

FileVersion.bat contains:

@echo off
if \{%1\}==\{\} goto syntax
if not exist %1 goto syntax
for /f "Tokens=5" %%a in ('filever %1') do set version=%%a
goto :EOF
set version=
@echo Syntax: FileVersion FQFilename