The default MS-DOS shell, COMMAND.COM, does not provide any way to redirect standard error. Doing this requires a different shell, or an external utility. (This problem is sufficiently well known that some command-line programs provide dedicated options to write error messages into a file. NASM, for example offers a -Z option, previously spelt -E, for that purpose.)
One such external utility is REDIR, found within the DJGPP distribution, which supports redirecting standard output and standard error both in overwrite and in append mode, joining the streams together, and a couple of other, mostly unrelated features. Like other DJGPP programs, it requires a DPMI DOS extender to run, so it can be considered relatively heavyweight.
If you are looking for something lighter, a program named ERROUT will suffice to join standard error into standard output, which is just enough to send verbose help output into a pager.
COMMAND.COM. – Stephen Kitt May 23 '23 at 11:56stderrto refer to a device rather than a file. I know that FreeCOM's interrupt 24h handler (Critical Error handler) expectsstderrto be open, and will apparently hang if you invoke the critical error handling whilestderris closed. I wrote about such a case some on my tech blog: https://pushbx.org/ecm/dokuwiki/doku.php?id=blog:pushbx:2023:0501_late_april_work_on_the_debugger#device_attribute_change – ecm May 23 '23 at 18:51stderrto (temporarily) replace both itsstdinandstdout, then operates on those using normal DOS functions. Here's the bit of the handler that does this replacement: https://github.com/FDOS/freecom/blob/1a8359c1683217c9bf9ebcca7e25258529c05e7e/criter/criter.asm#L400 I knew that it does this because it is expected thatstdinandstdoutmay be redirected using the shell's normal redirection capabilities. So the critical error handler must not use the original handles for those. – ecm May 23 '23 at 19:38