How to get Java version in a batch script subroutine?
问题 From this question: for /f "tokens=3" %%g in ('java -version 2^>^&1 ^| findstr /i "version"') do ( @echo Output: %%g set JAVAVER=%%g ) How can I put this into a subroutine and call it, passing a path to the java executable? Here's an example of my problem: @echo off setlocal enabledelayedexpansion call :GET_JAVA_VER "java" goto END :GET_JAVA_VER for /f "tokens=3" %%g in ('%1 -version 2^>^&1 ^| findstr /i "version"') do @echo %%g %1 -version 2>&1 | findstr /i "version" goto :EOF :END endlocal