MODE - Window Size and Key Repeat
Sometimes you want a bigger window to read long output, or you want every run of a batch file to start with the same screen size.
The MODE command displays and changes device settings for the console (the Command Prompt screen), such as the number of columns and lines and the keyboard repeat speed.
Check the current settings
Type mode con to display the current state of the console. con is the device name for the console.
mode con
The output and values vary by environment.
Change the window size
MODE CON: COLS=columns LINES=lines
Example
Set the window to 100 columns wide and 30 lines high.
mode con: cols=100 lines=30

中小企業経営者のためのRPA入門 RPA導入を成功させる方法

60分でわかる! AIエージェント 超入門

コマンドラインの黒い画面が怖いんです。

知識・才能ゼロでもらく~に月10万円稼ぐ! よくわかるAI副業超入門
You can also specify only one of COLS or LINES.
mode con: lines=40
There is also a shorthand that separates the columns and lines with a comma.
mode 100,30
In the classic console window (conhost), changing the size with mode con also makes the screen buffer (the area that keeps past output) the same size as the window. As a result, the scrollbar disappears and earlier output that has scrolled off the screen can no longer be viewed.
In Windows Terminal, which is the default terminal from Windows 11 22H2 onward, running mode con may not change the size of the window itself. In that case, resize the window with the mouse or change the terminal settings. The window size can mainly be set in the classic console window (conhost).
If you specify a value larger than the monitor resolution or font size allows, you may get an error or a size different from what you expected. Try smaller values first.
Fix the size at the top of a batch file
Put the command at the top of a batch file so that it starts with the same screen size every time.
@echo off
mode con: cols=80 lines=25
cls
echo ==============================
echo Menu
echo ==============================
echo 1. Backup
echo 2. Cleanup
echo ==============================
pause
Running cls after changing the size lets the display start from a clean screen.
Setting the colors and title as well makes a running batch file easier to recognize. See the color / title article for details.
Adjust the key repeat speed
mode con can also set how fast a character repeats when you hold down a key.
MODE CON: RATE=rate DELAY=delay
| Item | Description |
|---|---|
RATE | The speed at which characters repeat. Range 1 to 32; a larger number is faster |
DELAY | The wait before repeating starts. Range 1 to 4; 1 is 0.25 seconds and 4 is 1 second |
You must specify both RATE and DELAY at the same time.
mode con: rate=31 delay=1
Check the code page
Run mode con cp /status to check the current code page (character encoding).
mode con cp /status
The CHCP command is the usual way to change the code page. See the CHCP article for details.
When changes do not take effect
| Symptom | Main cause and fix |
|---|---|
| The window size does not change | You are running in Windows Terminal. Change it in the settings or try conhost |
| An error appears | The value is too large for the monitor or font. Try smaller values |
An error after specifying RATE only | RATE and DELAY must be specified together |
Besides the console described here, MODE can also configure communication settings for serial ports (such as COM1) and printer ports (such as LPT1). However, there are few occasions to use them today.
Summary
| Task | Command |
|---|---|
| Show current console settings | mode con |
| Set columns and lines | mode con: cols=100 lines=30 |
| Set them with the shorthand | mode 100,30 |
| Change only the height | mode con: lines=40 |
| Set the key repeat speed | mode con: rate=31 delay=1 |
| Check the code page | mode con cp /status |