JSI Tip 4890. How can I retrieve a files version in batch?
Jerold Schulman
February 26, 2002
1 Min Read
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%otepad.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
Example:
FileVersion %windir%otepad.exe sets the Version environment variable to 5.0.2140.1 on Windows 2000.
FileVersion.bat contains:
@echo offif {%1}=={} goto syntaxif not exist %1 goto syntaxfor /f "Tokens=5" %%a in ('filever %1') do set version=%%agoto :EOF:syntaxset version=@echo Syntax: FileVersion FQFilename
About the Author
Sign up for the ITPro Today newsletter
Stay on top of the IT universe with commentary, news analysis, how-to's, and tips delivered to your inbox daily.
You May Also Like