I have a windows command line script to run to check the java version, but it is outputting two additional rows(2 & 3) I don't need. I need it only to display the Echo of Current Java Version and the Java version number(1 & 3). Can you possibly assist with how I can modify the script?
Command being used:
C:\Windows\system32\cmd.exe /c echo Current Java Version & C:\Windows\system32\cmd.exe /c "for /f "tokens=3" %g in ('java -version 2^>^&1 ^| findstr /i "version"') do (@echo %g)"
Output from cmd window:
I had to remove the ( ) around the echo call after "do" as shown below. That resolved my issue:
C:\Windows\system32\cmd.exe /c echo Current Java Version & C:\Windows\system32\cmd.exe /c "for /f "tokens=3" %g in ('java -version 2^>^&1 ^| findstr /i "version"') do **@echo %g**"