(view source code of screen.bat as plain text)
@ECHO OFF
:: This batch file for NT shows 3 different ways to display text:: plus a way to overcome the problem that CLS is ignored when:: a batch file's output is redirected.:: Written by Rob van der Woude:: Since a simple CLS won't clear the screen when redirected,:: we need to use MODE to clear the screen instead.:: The FOR command is used to make sure we do not change the:: console settings when using MODE CON.FOR /F "TOKENS=2* DELIMS= " %%A IN ('MODE CON ^| FIND "Lines:"') DO SET LINES=%%A
MODE CON LINES=%LINES%
:: >CON writes directly to screen, blocking further redirectionECHO.>CON
ECHO.>CON
ECHO Different ways to display text on screen>CON
ECHO.>CON
ECHO CON Try to get rid of this message:>CON
ECHO neither ^>NUL nor ^>NUL 2^>^&1 will work>CON
ECHO.>CON
:: 1>&2 redirects output to standard error, enabling further:: redirection with 2>NULECHO STDERR Standard error can be suppressed with 2^>NUL, 1>&2
ECHO but not with ^>NUL 1>&2
ECHO. 1>&2
:: Standard output can be redirected using >NUL or 1>NULECHO STDOUT Standard output can be suppressed with ^>NUL,
ECHO but not with 2^>NUL
page last modified: 2025-10-11; loaded in 0.0051 seconds