DOS Concepts: Console, CON
By default, the DOS system receives user instructions from the keyboard and outputs the execution results of commands to the display screen. When the syntax or error message of a DOS command mentions the console, it actually refers to the monitor and keyboard as a unit.
The DOS system has an internal device driver called CON, which allows users to access the console when a printer or other device is connected to the system. The most important thing to remember about the console CON is: when a DOS command refers to CON, if CON is used as a source parameter, then CON refers to the keyboard; if CON is used as a target parameter, then CON refers to the screen.
Please see the following two examples.
Example 1. Create a batch file TIMEDATE.BAT.
COPY CON TIMEDATE.BAT
TIME
DATE
^Z
We are concerned with the command "COPY CON TIMEDATE.BAT". Here, CON is the source parameter, referring to the keyboard, and TIMEDATE.BAT is the target file. The whole sentence means that it copies from the keyboard to the TIMEDATE.BAT file.
Example 2. Look at the opposite process of Example 1.
COPY CONFIG.SYS CON
Here, CONFIG.SYS is the source file, and CON is the target parameter, referring to the screen. The whole sentence means that it copies CONFIG.SYS to the screen, and its function is equivalent to TYPE CONFIG.SYS.
Example 3. Use the printer as a typewriter.
COPY CON PRN
Here, CON is the source parameter, which is the keyboard, and the target parameter is PRN (printer driver, accessing the printer connected to LPT1). After executing this command, DOS waits for the user to input from the keyboard. When the input is finished, press F6 and enter, and the printer will immediately output the text that the user just entered.
By default, the DOS system receives user instructions from the keyboard and outputs the execution results of commands to the display screen. When the syntax or error message of a DOS command mentions the console, it actually refers to the monitor and keyboard as a unit.
The DOS system has an internal device driver called CON, which allows users to access the console when a printer or other device is connected to the system. The most important thing to remember about the console CON is: when a DOS command refers to CON, if CON is used as a source parameter, then CON refers to the keyboard; if CON is used as a target parameter, then CON refers to the screen.
Please see the following two examples.
Example 1. Create a batch file TIMEDATE.BAT.
COPY CON TIMEDATE.BAT
TIME
DATE
^Z
We are concerned with the command "COPY CON TIMEDATE.BAT". Here, CON is the source parameter, referring to the keyboard, and TIMEDATE.BAT is the target file. The whole sentence means that it copies from the keyboard to the TIMEDATE.BAT file.
Example 2. Look at the opposite process of Example 1.
COPY CONFIG.SYS CON
Here, CONFIG.SYS is the source file, and CON is the target parameter, referring to the screen. The whole sentence means that it copies CONFIG.SYS to the screen, and its function is equivalent to TYPE CONFIG.SYS.
Example 3. Use the printer as a typewriter.
COPY CON PRN
Here, CON is the source parameter, which is the keyboard, and the target parameter is PRN (printer driver, accessing the printer connected to LPT1). After executing this command, DOS waits for the user to input from the keyboard. When the input is finished, press F6 and enter, and the printer will immediately output the text that the user just entered.


