Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

print exit code in cmd in windows os [duplicate]

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

like image 442
Osama Ahmad Avatar asked Sep 29 '10 07:09

Osama Ahmad


People also ask

How do I duplicate in cmd?

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.

How do you get the last code out of Exit command?

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.

What is the command to check exit code?

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.


1 Answers

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.

like image 151
Adrian Fâciu Avatar answered Nov 10 '22 07:11

Adrian Fâciu