Set the screen size buffer in VBScript or bat

August 29, 2009 at 06:54:42
Specs: Windows XP Pro SP3
I want to set the screen buffer size of a command window from a batch file.
(buffer size, not number of rows/columns using mode con...)

Searching in google I see that it is possible in Unix using its stty command. But I could not found any stty replacement for Windows.

Some one knows any method to achive this from a bat or VBScript?

There is a related post here but it is too old and now I include the vbs possibility to solve this. So I think I am not being inopportune.

I want to set rows to 1000.

Thanks in advance!

See More: Set the screen size buffer in VBScript or bat

Report •

August 29, 2009 at 08:15:04
You'd need a language that can load and use .DLL's. Batch and VBScripts cannot.

Failing that, there's always third party apps.

Or you could write one yourself; it'd only be a few dozen lines in C or C++.

Report •

August 29, 2009 at 09:21:21
I had I quick stab at writing a quick and dirty c++ app to
do this, no error checking!

It seems to have a problem with small values (10 20?) on my
system(buffer re-size errors out with code 87 - invalid
parameter....), I can only guess it cause, probably
the minimum size msdn refers to...

//compiled on dev-c++
#include <iostream>
#include <windows.h>
using namespace std;

int main(int argc, char *argv[])
    COORD buff = {atoi(argv[1]), atoi(argv[2])};
    if (argc != 3 || buff.X <= 0 ||  buff.Y <= 0)
        cout << "2 Argument - <Buffer Size X> <Buffer Size Y> - Zero values not excepted" << endl;
        return 1;
    GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &maxcell);
    if (maxcell.srWindow.Right >= buff.X)
        maxcell.srWindow.Right = buff.X - 1;
    if (maxcell.srWindow.Bottom >= buff.Y)
        maxcell.srWindow.Bottom = buff.Y - 1;
    SetConsoleWindowInfo(GetStdHandle(STD_OUTPUT_HANDLE), TRUE, &maxcell.srWindow);
    SetConsoleScreenBufferSize(GetStdHandle(STD_OUTPUT_HANDLE), buff);
    return 0;

Report •

August 29, 2009 at 12:04:29
Judago and Razor, I am sorry I waste your time. I have already tested Mode Con command to set screen height so that it was possible to scroll up and down. And it did not work. I probably did the test in Win XP SP1 or even in a Win98 station.

Now, in WinXP SP3, I repeated the test: mode com lines=1200
To my surprise it worked!

There is an old topic with the same answer as mine and it had no solution. The solution came with Windows update.

Old topic:

Thank you very much. And excuse my fault, I should have tested it again.

Report •

Related Solutions

August 29, 2009 at 18:11:02
No problem for me, I thought it may have been the way "mode con:cols=<highnumber> lines=<highnumber>" resizes the window and not just the buffer......

I probably did the test in Win XP SP1 or even in a Win98 station.

That could be the issuse, I don't believe windows 98 support large buffers(larger than screen size?).

Report •

Ask Question