Redirect Execution Errors to NUL in MS-DOS 6.22

In MS-DOS 6.22, handling execution errors differs from modern command-line environments because the default shell, COMMAND.COM, does not natively support standard error (stderr) redirection. This article explains the technical limitations of error redirection in MS-DOS 6.22, standard output suppression syntax, and the common workarounds used to suppress or hide error messages during command execution.

The Limitation of COMMAND.COM

In modern shells such as the Windows Command Prompt (cmd.exe) or Unix shells, error output is redirected using the file descriptor syntax 2>NUL. However, MS-DOS 6.22 does not recognize numeric stream handles. If you attempt to run:

command 2>NUL

COMMAND.COM treats the 2 as a command-line argument rather than a stream redirector. While standard output (stdout) is redirected to NUL, error messages written directly to stderr will still display on the screen.

Standard Output Redirection

For programs and internal DOS commands that send status and non-critical messages through standard output, standard redirection to the null device is sufficient:

command > NUL

To suppress both standard output and input prompts, input and output redirection can be combined:

command > NUL < NUL

However, any true errors written directly to the console or stderr bypass this redirection.

Workaround 1: Suppressing Output Using CTTY

The most reliable native method in MS-DOS 6.22 to hide all screen output—including errors and hardware alerts—is to change the active console device to NUL using the CTTY command before running the task, and then restoring it back to CON.

@echo off
ctty NUL
command
ctty CON

Caution: While CTTY NUL is active, the system stops accepting keyboard input. If the executed program hangs or waits for user confirmation, the system will freeze and require a hard reboot.

Workaround 2: Using Third-Party Redirection Utilities

During the MS-DOS era, developers frequently utilized small assembly utilities to reroute standard error to standard output or directly to NUL.

One common utility was REDIR.EXE (or similar public-domain tools like ERROUT), which intercepted DOS handle 2 before executing a program:

redir /e NUL command

Workaround 3: Replacement Shells (4DOS)

Users seeking modern redirection capabilities in MS-DOS 6.22 often replaced COMMAND.COM with 4DOS, a widely adopted third-party command processor. 4DOS natively supports stream redirection:

command >& NUL

This syntax redirects both standard output and standard error to the NUL device simultaneously.