Code:
For /F "Tokens=2* skip=2" %%I In ('REG Query HKLM\Software\Microsoft\Windows\CurrentVersion\Uninstall\{0000C40F-A401-4C9C-AF3E-0382E92E1E22} /v DisplayVersion') Do Set _Version=%%J
If "%_Version:~0,4%"=="4.21" Echo Program A version %_Version% is installed.
If "%_Version:~0,4%"=="4.11" Echo Program B version %_Version% is installed.
)
That should do it. If you don't want to display the full version, use the same clause in the Echo Statement: "%_Version:~1,4%" instead of %_Version%
And to display just the first three digits
Code:
For /F "Tokens=2* skip=2" %%I In ('REG Query HKLM\Software\Microsoft\Windows\CurrentVersion\Uninstall\{0000C40F-A401-4C9C-AF3E-0382E92E1E22} /v DisplayVersion') Do Set _Version=%%J
If "%_Version:~0,4%"=="4.21" Echo Program A version %_Version:~0,4% is installed.
If "%_Version:~0,4%"=="4.11" Echo Program B version %_Version:~0,4% is installed.
)
Or just hard code in the 4.11 or 4.22 in the Echo statement portion