I'm analyzing a code of a former worker that does not work here anymore and he used alot this command:
dir >NUL
I know that this redirects the output to a "Nul device" and that CMD.EXE interprets it as dir 1>Nul but I do not see the purpose of it. He wrote as comment: Reset errorlevel.
Example:
for /f "tokens=2-4 delims=/ " %%a in ('date /t') do (set _Year=%%c&set _Month=%%a&set _Day=%%b)
set _Day=%_Day: =%
set _TODAY_FORMATTED=%_Year%%_Month%%_Day%
:: Self Check
:: Reset errorlevel
dir >NUL
set /a _TEST=%_TODAY_FORMATTED%-1
set _rc=%errorlevel%
:: Reset errorlevel
dir >NUL
if %_rc% NEQ 0 call :SELFCHECKERROR& goto end