The numbers zero through nine (that is, 0-9) represent the first 10 handles. You can use Cmd.exe to run a program and redirect any of the first 10 handles for the program. To specify which handle you want to use, type the number of the handle before the redirection operator. If you do not define a handle, the default < redirection input operator is zero (0) and the default > redirection output operator is one (1). After you type the < or > operator, you must specify where you want to read or write the data. You can specify a file name or another existing handle.
时间: 2023-12-28 14:04:33 浏览: 201
That's correct! When running a program in Cmd.exe, you can redirect any of the first 10 handles by specifying their number before the redirection operator. Handle 0 represents standard input (stdin), handle 1 represents standard output (stdout), and handle 2 represents standard error (stderr).
For example, to redirect the output of a program to a file called "output.txt", you would use the command:
```
program.exe > output.txt
```
This redirects standard output (handle 1) to the file "output.txt". If you wanted to redirect standard error instead, you would use the number 2 before the redirection operator:
```
program.exe 2> error.txt
```
This redirects standard error (handle 2) to the file "error.txt".
阅读全文