What are the ERRORLEVEL values set by internal cmd.exe commands?
<p>The ERRORLEVEL is a value returned by most cmd.exe commands when they end that change depending on a series of conditions, so knowing the value that the commands return is valuable information that may aid to write better Batch files. All external .exe programs change the ERRORLEVEL when they end (that is an inherent mechanism of both <a href="https://msdn.microsoft.com/en-us/library/ms682658(v=vs.85).aspx" rel="noreferrer">ExitProcess</a> and <a href="https://msdn.microsoft.com/en-us/library/ms686714(v=vs.85).aspx" rel="noreferrer">TerminateProcess</a> Win-32 API functions) and usually such values are documented, but the values returned by <em>internal</em> cmd.exe commands are not fully documented elsewhere.</p>

<p>A table with partial ERRORLEVEL values appears at <a href="https://stackoverflow.com/questions/34968009/which-cmd-exe-internal-commands-clear-the-errorlevel-to-0-upon-success">this question</a>, but just for internal commands that set ERRORLEVEL=0 "upon success". I suggested the OP of such question to modify it in order to also include the values returned by "not successful commands", but he refused and invited me to post my own question/answer, so here it is! You must note that an ERRORLEVEL different than zero does <em>not</em> necessarily means that the command failed! There are some commands that end with no error and return a value greater than zero to indicate different "exit status", including internal commands (like <code>SET /P</code>).</p>

<p>To make better use of the built-in cmd.exe commands in Batch .bat files we need to know the ERRORLEVEL values they return and the mechanisms involved in this management. So the question is, which <strong>internal cmd.exe commands</strong> set the ERRORLEVEL to <em>any value</em> (including zero)?</p>