Is Windows %ERRORLEVEL% == $? in Linux
<p>Trying my hands on windows batch files, in the below code that I found by searching in www.</p>

<pre><code>@ECHO OFF
REM Call this with two arguments, and it will add them.
SET a=%1+%2
IF %ERRORLEVEL%==0 (goto errors-0) ELSE (goto errors-1)
REM Instead of using goto with the variable, this uses an IF-ELSE structure
:errors-0
REM This is if it was successful
ECHO %a%
goto exit
:errors-1
REM this is if it had an error:
ECHO Errors occurred.
goto exit
REM GUESS WHAT, THIS REM WILL NEVER EVER BE READ!  IT WILL BE SKIPPED OVER BY THE GOTOS
:exit
ECHO.
ECHO press any key to exit.
PAUSE&gt;nul
</code></pre>

<p>The code is suppose to take 2 arguments, add them and echo the result.</p>

<p>But this won't execute with success on my Windows 8.1 machine. Below is what I get:</p>

<pre><code>C:\ProjectDoc&gt;add3.bat
Errors occurred.

press any key to exit.
</code></pre>

<p>So, U added an echo for the <code>ERRORLEVEL</code> to see its value after executing the command <code>SET</code>. Below is the output:</p>

<pre><code>C:\ProjectDoc&gt;add3.bat 2 3
9009
Errors occurred.

press any key to exit.
C:\ProjectDoc&gt;
</code></pre>

<p>So, is this <code>errorlevel</code> in Windows equal to the <code>$?</code> of Linux. Should it be returning 0 for every successful execution of a command or is it different? Reading some docs relates it to the Linux <code>$?</code> but it isn't clearly working as <code>$?</code> in Linux.</p>