nul 2>&1 0>con comp nul nul 0>nul Comm...">

Why can't I get user input when & 0 stream is redirected

Examples:

set /p= 0>nul
runas /user:"" "" >nul 2>&1 0>con
comp nul nul 0>nul

Commands are executed like pressing the enter key. I would rather expect something like this when input redirection is used but not output.

+4
source share
1 answer

Follow MS documentacion .

We have duplicate descriptors

2>&1   : Take the handle in the stream 1, 
         duplicate it 
         and place the copy as the handle in stream 2.

and redirection operators

2>file : Get a handle to the file and 
         place the handle to be used as stream 2

<file  : Get a handle to the file and
         place the handle to be used as stream 1 (implicit)

In all cases, the handle is obtained (copied or not) and placed as a handle for the specified stream.

Now your code

set /p= 0>nul
        ^^^^^ .... What does it mean? 

This means: open the stream to the nul“device” and set the handle to this stream (copy / duplicate it) as the handle to stream 0

, ( , . )

set /p= <nul
set /p= 0>nul

, &0, nul.

, .

set /p= 0<con set /p= 0>con ?

, - . , , &0 , ?

. , &0, , , . , :

  • <
  • >

,

  • , ,
  • , ,
+2

All Articles