print exit code in cmd in windows os ....some command return exit code ...where this code store...and i want to print this exit code and assign it to variable
Click Start, type cmd, and press Enter to open a command prompt window. In the Windows taskbar, right-click the command prompt window icon and select Command Prompt. A second command prompt window is opened.
Extracting the elusive exit code To display the exit code for the last command you ran on the command line, use the following command: $ echo $? The displayed response contains no pomp or circumstance. It's simply a number.
How to find out the exit code of a command. echo $? printf '%d\n' $? From the above outputs, it is clear that the exit code is 0 indicates that date command was successful.
You can use %ERRORLEVEL% environment variable, it will hold the last code that was returned. You can echo it or assign it to a variable, depending on your needs.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With