I want to read the return code of a cmd
command in Java. For that I used:
Runtime.exec("echo %errorlevel%")
but instead of echoing the error code it is echoing %errorlevel%
.
Not sure what are you using this for. But it seems that you want exit code of the command you executed in you program.
If you have Process
object (corresponding to your command) available, you can either use process.waitFor()
or process.exitValue()
methods to get the exit code of your process.