This batch script can get file version of any application (*.exe ;*.dll) inside a directory (in my example i set “RootFolder=%ProgramData%”); so you can change it as you want like (set “RootFolder=%AppData%”) and so on …
Just Change this Variable in your case and the script will do the rest.
For any update just check this link : https://pastebin.com/uWscW7rU
GetFileVersion.bat
@echo off
Mode 75,3 & color 9E
Title Get File Version of any Application from file list using WMIC by Hackoo
::******************************************************************************
REM Just Change this Variable in your case and the script will do the rest (-_°)
Set "RootFolder=%ProgramData%"
::******************************************************************************
:Main
@for %%a in ("%RootFolder%") do set "FolderName=%%~na"
Set "File_Version_List=%~dp0%FolderName%_File_Version_List.txt"
Set "ErrorFile=%~dp0%FolderName%_Error.txt
Set Extensions="*.exe" "*.dll"
If exist "%ErrorFile%" Del "%ErrorFile%"
If exist "%File_Version_List%" Del "%File_Version_List%"
echo(
echo Please wait a while ... Process to get file version ...
set "BuildLineWith=call :BuildLine "
setlocal enabledelayedexpansion
CD /D "%RootFolder%"
@for /f "delims=" %%F in ('Dir /b /s %Extensions%') do (
set "Version="
Call :Get_AppName "%%F" AppName
Call :Add_backSlash "%%F"
Call :GetVersion !Application! Version
Call :Remove_backSlash !Application!
If defined Version (
(
echo !Application!
echo !AppName! ==^> !Version!
%BuildLineWith%*
)>> "%File_Version_List%"
) else (
(
echo Version is not defined in !Application!
%BuildLineWith%#
)>> "%ErrorFile%"
)
)
If Exist "%ErrorFile%" Start "" "%ErrorFile%"
If Exist "%File_Version_List%" Start "" /MAX "%File_Version_List%" & Exit
::*******************************************************************
:GetVersion
Rem The argument %~1 represent the full path of the application
Rem without the double quotes
Rem The argument %2 represent the variable to be set (in our case %2=Version)
FOR /F "tokens=2 delims==" %%I IN (
'wmic datafile where "name='%~1'" get version /format:Textvaluelist 2^>^nul'
) DO FOR /F "delims=" %%A IN ("%%I") DO SET "%2=%%A"
Exit /b
::*******************************************************************
:Add_backSlash
Rem Subroutine to replace the simple "\" by a double "\\" into a String
Set "Application=%1"
Set "String=\"
Set "NewString=\\"
Call Set "Application=%%Application:%String%=%NewString%%%"
Exit /b
::*******************************************************************
:Remove_backSlash
Rem Subroutine to replace the double "\\" by a simple "\" into a String
Set "Application=%1"
Set "String=\\"
Set "NewString=\"
Call Set "Application=%%Application:%String%=%NewString%%%"
Exit /b
::*******************************************************************
:Get_AppName
Rem %1 = FullPath
Rem %2 = AppName
for %%i in (%1) do set "%2=%%~nxi"
exit /b
::*******************************************************************
:BuildLine
REM Thanks to ImDeepWithWindows for this nice trick of BuildLine
set "LineChar=%1"
if "%LineChar%"=="" set "LineChar=_"
for /f "tokens=2 skip=4" %%A in ('mode con: /status') do set "WindowColumns=%%A" & goto :GotColumnCount
:GotColumnCount
set "CharLine="
setlocal EnableDelayedExpansion
for /L %%A in (1,1,%WindowColumns%) do set "CharLine=!CharLine!!LineChar:~0,1!"
setlocal DisableDelayedExpansion
endlocal
echo %CharLine%
goto :eof
::*******************************************************************