I am writing one batch setup program, and I have to check version of java during the setup. In order to do that I use the following code in my batch:
JAVA -version 2>&1 | FOR /F "USEBACKQ TOKENS=2 DELIMS=." %A IN (`FIND "VERSION" /I`) DO (IF 2 EQU 2 ECHO INSIDE IF STATEMENT.)
But for some reason this does not work, there appears the following error message:
2 was unexpected at this time.
If I do not pipe command to FOR
loop then IF
command gets executed.
If I put ECHO
outside IF
while piping, and do not use IF
, ECHO
gets executed.
So for some reason combination of piping and IF
command does not work.
What should I do?