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%.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
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
Processobject (corresponding to your command) available, you can either useprocess.waitFor()orprocess.exitValue()methods to get the exit code of your process.