Programming Field

Mode - DOS/Command Prompt Reference

Configures devices for DOS/Command Prompt.

Syntax

The syntax of this command varies depending on its purpose.

* [MS-DOS, Windows 95/98/Me only] PRN can be specified instead of LPT1.

1. Display device status

mode[.com] [<device>] [/STATUS]
<device> Specifies the device name (CON, COM1, LPT1, etc.; AUX and PRN cannot be specified). If /STATUS is specified, <device> is optional. If omitted, it will display the status of all devices.
/STATUS Displays the status of the device specified by <device>. This parameter is optional. /STATUS can also be specified as /STA.

2. Configure parallel (printer) port [MS-DOS, Windows 95/98/Me]

mode[.com] LPTn[:] [COLS=c] [LINES=l] [RETRY=r]
mode[.com] LPTn[:] [c][,[l][,r]]
LPTn[:] Specifies the device name for the parallel port. n can be 1, 2, 3, etc. The colon ‘:’ can be specified or omitted.
COLS=c Specifies the number of characters per line. The value for c can be 80 or 132. If this option is omitted, 80 is used.
LINES=l Specifies the number of lines per inch. The value for l can be 6 or 8. If this option is omitted, it is set to 6. ‘LINES=’ can be omitted, and only the numerical value (l) can be specified.
RETRY=r

Specifies the action to be taken when the output to this device times out. r will be as follows:

ValueAction
EReturns an error if the port is in a busy state when checking its status.
BReturns ‘Busy’ if the port is in a busy state when checking its status.
PContinues retrying until the device accepts the output.
RReturns ‘Ready’ if the port is in a busy state when checking its status.
NDoes not perform retries. If this option is omitted, it is considered as if this value were specified.
[c][,[l][,r]] The above options can also be specified shortly by separating them with a colon ‘,’. In this case, the order of values matters, so the colon cannot be omitted. For example, if omitting c and specifying l, you still need to specify it as ‘,6’.

3. Redirect parallel (printer) port to serial port

mode[.com] LPTn[:]=COMm[:]
LPTn[:] Specifies the device name for the parallel port where the output is performed. n can be 1, 2, 3, etc. The colon ‘:’ can be specified or omitted.
COMm[:] Specify the device name for the serial port to be the actual output destination. m can be 1, 2, 3, etc. The colon ‘:’ can be specified or omitted.

4. Configure serial port

mode[.com] COMm[:] [BAUD=b] [PARITY=p] [DATA=d] [STOP=s] [RETRY=r]
  [to=on|off] [xon=of|off] [odsr=on|off] [octs=on|off] [dtr=on|off|hs]
  [rts=on|off|hs|tg] [idsr=on|off]
mode[.com] COMm[:] [b[,[p][,[d][,[s][,r]]]]]
COMm[:] Specifies the device name for the serial port. m can be 1, 2, 3, etc. The colon ‘:’ can be specified or omitted.
BAUD=b

Specify the baud rate. b specifies the first two digits of the value to be specified. The following is the corresponding table:

ValueActual value [baud]
11110
15150
30300
60600
121200
242400
484800
969600
1919200

* The value 19 (19200) may not be supported by some devices.

[Windows 95/98/Me/NT series?/XP or later] The actual value (such as 9600) can also be directly specified. In this case, if the device supports it, you can specify values not listed in the above table (such as 119200).

PARITY=p Specifies the parity bit. The value for p can be N (none), E (even), O (odd), M (mark), or S (space). If this option is omitted, E is used. Note that M and S may not be supported by some devices.
DATA=d Specifies the number of bits per character. The value for d can be 5 to 8, and if this option is omitted, 7 is used. Note that 5 and 6 may not be supported by some devices.
STOP=s Specifies the number of stop bits. The value for s can be 1, 1.5, or 2. If the baud rate is 110 and this option is omitted, 2 is used; otherwise, 1 is used. Note that 1.5 may not be supported by some devices.
RETRY=r [MS-DOS, Windows 95/98/Me] Specifies the action to be taken when the output to this device times out. The values to be specified and the default value when this option is omitted are the same as the RETRY specification for the parallel port mentioned above.
to=on|off (Infinite timeout processing configuration)
xon=of|off (Setting for XON/XOFF protocol in data flow processing)
odsr=on|off (Setting for handshake using Data Set Ready (DSR) circuit)
octs=on|off (Setting for handshake using Clear To Send(CTS) circuit)
dtr=on|off|hs (Setting for Data Terminal Ready (DTR)) (* hs = handshake)
rts=on|off|hs|tg (Setting for Request To Send (RTS)) (* hs = handshake / tg = toggle)
idsr=on|off (Setting for Data Set Ready (DSR) circuit sensitivity) [Windows NT series?/XP or later] Perform additional settings for the device individually.
[b[,[p][,[d][,[s][,r]]]]] The above arguments can also be specified shortly by separating them with a colon ‘,’. In this case, the order of values matters, so the colon cannot be omitted. Also, the baud rate must be specified (omitting it will result in an error).

5. Configure code page

mode[.com] <device> CODEPAGE PREPARE=((yyy [yyy2 ...]) <file>)
mode[.com] <device> CODEPAGE SELECT=yyy
mode[.com] <device> CODEPAGE REFRESH
mode[.com] <device> CODEPAGE [/STATUS]
<device>

Specifies the device name (CON, COM1, LPT, etc.).([MS-DOS, Windows 95/98/Me] CON does not support code page changes.)

[Windows NT series?/XP or later] <device> can only be specified as CON.

CODEPAGE The setting for code page always includes ‘CODEPAGE’. ‘CODEPAGE’ can be abbreviated as ‘CP’.
PREPARE=((yyy [yyy2 ...]) <file>)

[MS-DOS, Windows 95/98/Me] Prepares by loading a file to make the code page available. yyy contains the code page number. <file> is the file name, which usually has the extension CPI and contains code page data. When specifying, parentheses ‘( )’ are required.

When specifying multiple code pages, use spaces to separate them, like yyy2 as above.

‘PREPARE’ can be abbreviated as ‘PREP’.

SELECT=yyy

Changes to the code page specified in yyy.

[MS-DOS, Windows 95/98/Me] yyy can only be specified if prepared with PREPARE. ‘SELECT’ can be abbreviated as ‘SEL’.

REFRESH [MS-DOS, Windows 95/98/Me] Used when reloading data, for example, if the data loaded with PREPARE is corrupted. ‘REFRESH’ can be abbreviated as ‘REF’.
/STATUS Display the status of the code page for the device specified by <device>. This parameter is optional. /STATUS can also be specified as /STA.

6. Configure screen / typematic rate

mode[.com] <display>
mode[.com] [<display>],L|R[,T]
mode[.com] CON[:] [COLS=c] [LINES=l]
mode[.com] CON[:] [RATE=r] [DELAY=d]
<display>

[MS-DOS, Windows 95/98/Me] Specifies the display adapter. The following values can be used:

ValueMeaning
40 or 80Sets the number of characters per line to 40 or 80.
BW40 or BW80Specifies the color graphics adapter (CGA) with color display disabled and sets the number of characters per line to 40 or 80.
CO40 or CO80Specifies the color display with color enabled and sets the number of characters per line to 40 or 80.
MONOSpecifies the monochrome display adapter with 80 characters per line.
L|R [MS-DOS, Windows 95/98/Me] Specifies the shift direction of the screen. L is left, R is right. This may not be applicable for all displays.
T [MS-DOS, Windows 95/98/Me] When specifying the shift direction of the screen, a test pattern is used to check whether the screen is set correctly. In this case, a prompt will be displayed to confirm if the screen is set correctly.
COLS=c

Specifies the number of characters per line. c will be that number. This may not be applicable for all displays.

[MS-DOS, Windows 95/98/Me] The value that can be specified for c is 40 or 80.

LINES=l

Specifies the number of lines per screen. l will be that number. This may not be applicable for all displays.

[MS-DOS, Windows 95/98/Me] The value that can be specified for l is 25, 43, or 50.

RATE=r

Sets the repeat time (time until repetition) when a key is held down. A larger value specified for r will make it faster.

[MS-DOS, Windows 95/98/Me] The value that can be specified for r is 1 to 32. It also needs to be specified simultaneously with DELAY.

DELAY=d

Sets the initial delay time (time until the first repetition starts) when a key is held down. A larger value specified for d will make it slower.

[MS-DOS, Windows 95/98/Me] The value that can be specified for d is 1 to 4, representing 0.25 seconds, 0.5 seconds, 0.75 seconds, and 1 second, respectively. It also needs to be specified simultaneously with RATE.

Details

Usage of Mode

This program makes various settings for devices on MS-DOS. However, these settings will be lost upon restarting. If executed in a Windows prompt, they will only be effective within that prompt.

If you want to send and receive data using serial ports or parallel ports, you can use COMn or LPTn as files, along with the Type command or the Echo command and output redirection.

[Windows NT series?/XP or later] It is possible to change the code page of the console (CON) with Mode, serving as an alternative to the Chcp command.

Samples

Sample 1

mode COM1: baud=119200 parity=e data=8 stop=1
type COM1

[Windows 95/98/Me ?/NT series?/XP or later] Adjusts the settings for the serial port COM1 and then outputs the data sent to COM1 on the console.

Sample 2

mode CON cp select=65001 > NUL

[Windows NT series?/XP or later] Changes the code page setting of the console to UTF-8.

See also