Search notes:

cmd.exe: The %errorlevel% (pseudo-) variable

The pseudo (or dynamic) variable %errorlevel% evaluates to the return (or error) code of the most recent command (with some exception) that was executed.
Such a command can be both, a cmd.exe built-in command or an external executable (*.exe), such as findstr.exe.
A batch file can use exit /b N to pass a numerical value (N) to a caller using the %errorlevel% variable.

See also

choice.exe uses the %errorlevel% variable to return a number to the caller.
The PowerShell automatic variable $lastExitCode.

Index