Change Command Prompt width from the Command Line

5,005

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).

enter image description here

Go under the Layout Tab and select the Width. You can change this value to your likings

enter image description here

Profit. :)

enter image description here

Solution 3

You have two options:

  1. You can change the window size via code (I don't know how do it from Ruby)
  2. Have your users click on the icon in the top left corner and go to properties, in layout you can set the size.

enter image description here

Share:
5,005

Related videos on Youtube

Starkers
Author by

Starkers

Updated on September 18, 2022

Comments

  • Starkers
    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?

    command prompt

    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
      kobaltz over 10 years
      I do not know if you can do this from the prompt, but you can do this using the GUI.
    • Austin T French
      Austin T French over 10 years
      Your 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
      Starkers over 10 years
      Fair point, edited
    • Oliver Salzburg
      Oliver Salzburg over 10 years
      You can also check my related question: superuser.com/questions/653390/…
  • Starkers
    Starkers over 10 years
    Hi 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
    Scott Chamberlain over 10 years
    As 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
    Debra over 10 years
    May also help you to drop the font size, while you're at it.
  • phuclv
    phuclv over 10 years
    for changing the size by code you can do like my answer