Define a new descriptor (similar to STDOUT)

I looked at redirecting handles in batch mode when I noticed this:

Table from wikipedia page

Here's the link

It mentions that descriptors 3–9 are undefined and can be defined by the program. Now I read about it in C #, but I was wondering if this is possible in cmd / batch, and if so, what are its limitations / uses.

If this is not possible in cmd, how would I use it, and could it be a solution to output the data to the screen and redirect it to a file at the same time (a problem that was not able to be legal at the same time )

Thanks Mona.

+4
source share
1 answer

: STDIN (SET/P) STDOUT (ECHO ..); . ? : (3-9) (SET/P < & #) (ECHO > & #).

3 :

@echo off
setlocal EnableDelayedExpansion
3<input2.txt 4<input3.txt (
for /F "delims=" %%a in (input1.txt) do (
   set line=
   rem Read from input2.txt (and write line from input1 to output.txt):
   set /P line=%%a <&3
   rem Read from input3.txt (and write line from input2 to output.txt):
   set /P line=!line! <&4
   rem Write line from input3 to output.txt:
   echo(!line!
)
) >output.txt

.

:

+6

All Articles