Compare File Versions (low or high) command(.cmd)

I extracted the "chrome.exe" version with the command below. I want to get the value compared to the extracted version.

setlocal enableDelayedExpansion

FOR /F "tokens=2 delims==" %%I IN (
  'wmic datafile where "name='C:\\Program Files\\Google\\Chrome\\Application\\chrome.exe'" get version /format:list'
) DO FOR /F "delims=" %%A IN ("%%I") DO SET "ChromeVersion=%%A"

if version=94.0.4606.71 

I want Exit if higher than the version value.
if %ChromeVersion%==higher goto end

Install if lower than the version value.
if %ChromeVersion%==lower goto install


@echo off 

for /f usebackq^tokens^=3 %%i in (
  `reg query HKEY_CURRENT_USER\Software\Google\Chrome\BLBeacon /v version`
   )do set "_current=%%~i"
 
 set "_version=94.0.4606.71"
 set "_current=%_current:.=%0000000"

 if %_current:~0,9% lss %_version:.=% (
      goto :install )else goto :eOf

You don't need to use a double for to do this, hence no need to use setlocal enableDelayedExpansion


Some further reading:

  • Set /?

  • Where does GOTO :EOF return to?

  • If condition() else condition()

  • Goto :Label /? | or | Call :Label /?

  • Set variable=variable:substrings | DOS - String Manipulation

  • Reg Query | Windows Registry location for Google Chrome version


Thanks for the help. I have implemented the action I want.

set ChromeDeploryVersion=94.0.4606.71

for /f usebackq^tokens^=3 %%i in (
  `reg query HKEY_CURRENT_USER\Software\Google\Chrome\BLBeacon /v version`
   )do set "_current=%%~i"
echo.
echo The current version of Chrome is %_current%
echo.
 set "_version=%ChromeDeploryVersion%"
 
  if %_current%==%ChromeDeploryVersion% goto VersionSame
 
 set "_current=%_current:.=%0000000"
 
 if %_current:~0,9% lss %_version:.=% (
      goto :install) else (goto :HighVersion
      )

:VersionSame
echo.
echo.
echo ▶ Chrome version is same.
echo.
echo.
goto end

:install 
echo.
echo.
echo ▶ Chrome version is low.
echo.
echo.
goto end

:HighVersion
echo.
echo.
echo ▶ Chrome version is high.
echo.
echo.
goto end