Change Command Prompt width from the Command Line
Solution 1
You can change by the command mode con
For example to change the size to 120x40
mode con:cols=120 lines=40
You can also change only the width or height by specifying cols
or lines
mode con: lines=40
The space between con:
and cols
or lines
is optional
I don't know if Ruby can access windows APIs or not, but you can execute the above commands to change the size as you wish. If it doesn't support running command directly then you can run it through cmd
cmd.exe /c mode con:cols=NUMCOLS lines=NUMLINES
For some other languages you can directly change the size of console window through console API
using System;
class Program
{
static void Main()
{
Console.SetBufferSize(100, 9999);
}
}
EDIT: A shorter command
mode WIDTH,HEIGHT
mode 120,40
It's an undocumented feature of mode command
Syntax
...
Display size - number of columns wide and number of lines deep:
MODE CON[:] [COLS=c] [LINES=n]
undocumented) abbreviated version of the above:
MODE Cols, Lines
Solution 2
Right Click on the Title Bar and select Properties or Defaults (if you want this change to persist).
Go under the Layout Tab and select the Width. You can change this value to your likings
Profit. :)
Solution 3
You have two options:
- You can change the window size via code (I don't know how do it from Ruby)
- Have your users click on the icon in the top left corner and go to
properties
, inlayout
you can set the size.
Related videos on Youtube
Starkers
Updated on September 18, 2022Comments
-
Starkers over 1 year
Don't really know what more I can say really. That window captured below will simply not get any larger. Are there some settings somewhere that will allow me to resize it?
See, this limited window thing has left me in a bit of a pickle. Basically I've created an application with a command line GUI (With Ruby's Curses Library), and while everything works beautifully on OSX and Ubuntu Terminals, with Command Prompt, if the Curses Windows are larger than the Command Prompt window as shown below, the whole application crashes with a 'window already closed' error.
So, is there a setting that allows users to resize their Command Prompt window, something that I'll have to put in the documentation.
Here's what the holy grail answer would, be though:
Is there a way to do this from the command line? Could my application detect if the Command Prompt it's running on is of fixed width, and actually programatically run the command to allow the Command Prompt window to be enlarged? Or at least give the user a helpful error message?
-
kobaltz over 10 yearsI do not know if you can do this from the prompt, but you can do this using the GUI.
-
Austin T French over 10 yearsYour title does not match your "holy grail" answer. As you ask why in the title, but ask for how and processes in the question/
-
Starkers over 10 yearsFair point, edited
-
Oliver Salzburg over 10 yearsYou can also check my related question: superuser.com/questions/653390/…
-
-
Starkers over 10 yearsHi Scott! You say " You can change the window size via code " so it is possible to do this with Ruby? Or at least a programming language? I thought I'd have to figure out how to somehow run Command Prompt 'commands', but it can be done with a language?
-
Scott Chamberlain over 10 yearsAs I said, I don't know the Ruby language to know how to do it or if it is even possible, but here is how you do it in powershell.
-
Debra over 10 yearsMay also help you to drop the font size, while you're at it.
-
phuclv over 10 yearsfor changing the size by code you can do like my answer