Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I can change the size of a Command Prompt window like this:

'mode con:cols=920 lines=40'

But how can I keep the window the same size but increase the buffer size (make the scoll bars smaller, if you follow me) from the command line?

I'm running Windows 7, but I would like a command that works in all Windows versions. It's a simple operation, so I think we're okay.

share|improve this question

The mode command does not (directly) alter the size of the window, it alters the size of the buffer. If you set the numbers to something larger than the window size and it will create scrollbars as necessary. Setting it to numbers smaller than the window will remove the scrollbars and the window will shrink.

There is a StackOverflow question that gives some more solutions for finer-grained control via the registry or programming if you are interested.

share|improve this answer
What can I say, it's definitely enlarging the Command Prompt window! Oh well, it's working okay – Starkers Oct 17 '13 at 19:50
Like I said, it’ll adjust the window size to the buffer as necessary. It does the same thing when you modify the buffer size via the Properties dialog. What you need to do is to change the buffer size, then reset the window size to what it was. There are no commands that can alter the window size, so you need to use one of the tricks in the SO page. You can use a registry hack, a third-party tool (e.g., conutils), or compile your own program (e.g., VB, C#). – Synetech Oct 17 '13 at 23:00

MODE CON: lists the buffer size, but not the window size.

MODE CON: cols=N1 lines=N2 set both both the window and buffer to the same dimensions.

You want to increase the buffer size without changing the window size.

The StackOverflow answer to CMD: Set buffer height independently of window height shows how to set the buffer and window sizes independently via PowerShell.

A slight modification will set the buffer size without changing the window size:

@echo off
:conBufferSize  bufWidth  bufHeight
powershell -command "&{$H=get-host;$W=$H.ui.rawui;$B=$W.buffersize;$B.width=%1;$B.height=%2;$W.buffersize=$B;}"

Note that the buffer size must be larger than the current window size.


Below is a modified version that checks the current window width and height and sets the buffer dimension to the window dimension if the provided buffer dimension is too small.

@echo off
:conBufferSize  bufWidth  bufHeight
powershell -command "&{$H=get-host;$W=$H.ui.rawui;$B=$W.buffersize;$S=$W.windowsize;$B.width=if (%1 -gt $S.width) {%1} else {$S.width};$B.height=if (%2 -gt $S.height) {%2} else {$S.height};$W.buffersize=$B;}"
share|improve this answer
That changes the window size. – Synetech Oct 17 '13 at 23:01
@Synetech - I don't see how my code can ever change the window size, given that it doesn't access those attributes. I've tested the above, and it works perfectly for me. It changes the buffer size and leaves the window size as is. – dbenham Oct 17 '13 at 23:49
Exactly, as I said in the last line of the answer - the selected buffer size must be larger than (actually greater than or equal to) the window size. It works without error with properly sized buffer. Additional PowerShell code can be used to get the current window size and adjust the buffer size to match if the selected buffer size is too small. – dbenham Oct 18 '13 at 1:49
It’s probably easier to just use a third-party tool or compiled program. That way it can get the current window size and handle everything. I’m half tempted to throw one together. :-/ – Synetech Oct 18 '13 at 1:53
@Synetech - I added another version that checks the size and compensates as appropriate. – dbenham Oct 18 '13 at 2:15

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .