I was working on a batch file last week and I needed to have access to an executable fileâs details (specifically, the version). In some situations when a program is installed through Windows Installer you can access a programâs version from the registry, however, in my situation the file simply exists and was not installed.
The information that I needed access to can be found under the âDetailsâ tab when you Right-Click / Properties. Here, I am interested in the VNCViewerâs version.
It took a while to come up with this method as I couldnât easily find a way to access this from the Command Prompt / DOS. Unable to find anything, I decided to look into using WMI from DOS. Thatâs when I came up with the following using WMIC.
WMIC Path CIM_DataFile WHERE Name='%ProgramFiles:\=\\%\\UltraVNC\\vncviewer.exe' Get Version
This should work on any file that has the correct meta data embedded into it. To use this command in a batch file so I could compare versions, I did the following.
SET WMICCommand="WMIC Path CIM_DataFile WHERE Name='%ProgramFiles:\=\\%\\UltraVNC\\vncviewer.exe' Get Version"
REM Get the version of VNC viewer.
FOR /F "skip=1" %%X IN ('%WMICCommand%') DO (
IF %%X == 1.0.9.6 GOTO :CORRECTVERSION
)
Hope this makes some of your searches easier!