3

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?

4
  • I do not know if you can do this from the prompt, but you can do this using the GUI.
    – kobaltz
    Oct 17, 2013 at 15:03
  • 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/ Oct 17, 2013 at 15:13
  • Fair point, edited
    – Starkers
    Oct 17, 2013 at 15:19
  • You can also check my related question: superuser.com/questions/653390/… Oct 17, 2013 at 16:06

3 Answers 3

6

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
2

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

3
  • 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?
    – Starkers
    Oct 17, 2013 at 15:07
  • 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. Oct 17, 2013 at 15:08
  • for changing the size by code you can do like my answer
    – phuclv
    Oct 17, 2013 at 23:57
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

3
  • 1
    select defaults instead of properties will save the options for all future command prompt windows
    – phuclv
    Oct 17, 2013 at 15:08
  • Good point. I'll update the answer.
    – kobaltz
    Oct 17, 2013 at 15:10
  • May also help you to drop the font size, while you're at it.
    – Debra
    Oct 17, 2013 at 23:09

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