27

Is it possible to programmatically, or otherwise, increase the width of the Windows console window? Or do I need to create a wrapper program that looks and acts like the console somehow? Are there any programs around that do this already? I use Cygwin extensively in my development, and it seems a little ridiculous to me that all console windows in Windows are width limited.

If it matters at all, I'm running Windows XP.

Jason Plank
  • 2,336
  • 5
  • 31
  • 40
Matthew Scharley
  • 127,823
  • 52
  • 194
  • 222

11 Answers11

57

Simply run "mode cols,lines" to change the size of the current console window:

mode 120,60

will resize the console window to 120 columns and 60 lines

  • As I've discovered, thanks to this answer, running mode with no parameters will return all kinds of useful info, including columns and lines. Useful if you simply want to see what it is, rather than change it. You can parse it with cscript, too, if you need to size your command output to fit the user's settings. – alfadog67 Jan 19 '16 at 17:02
  • 1
    Unfortunately, this will also set the screen buffer size to these value (i.e. disable vertical scrolling). – Sebastian Krysmanski Apr 04 '17 at 13:02
22

You can increase it manually by right-clicking the tray icon and entering the options dialog.

There are also third-party terminal emulators for Windows, such as Console:

Screenshot of Console

Glorfindel
  • 21,988
  • 13
  • 81
  • 109
John Millikin
  • 197,344
  • 39
  • 212
  • 226
11
system("mode 45, 20");

This is a bad solution because it disables vertical scrolling.

This is better:

system("mode CON: COLS=120");
Peter O.
  • 32,158
  • 14
  • 82
  • 96
Sergey
  • 1,552
  • 20
  • 18
6

If you right click on the title bar of a command window and choose properties, you can change widths in the Layout tab

Carl
  • 5,881
  • 4
  • 25
  • 24
  • Wow, much nicer. This is where I hang up my hat in shame. This allows you to set a default for individual links/programs, but is there a way to set a universal default? – Matthew Scharley Oct 10 '08 at 08:49
  • 1
    It allows you to set settings for the title window. If you open up cmd.exe then you can set it for that. It should work for most windows then on out. – Henry B Oct 10 '08 at 09:08
  • Yeah, I found that after I set it on cmd.exe it seemed to work on all the other things that I have used since. It didn't seem to have affected a console app that I build in .NET, so I changed the properties in the same way and it seems to have persisted even between builds – Carl Oct 10 '08 at 12:37
5

If you're programming C# here's a method that worked for me (from the bottom of this page)

static void setConsoleSize()
   {
       System.Console.SetWindowPosition(0,0);   // sets window position to upper left
       System.Console.SetBufferSize(200,300);   // make sure buffer is bigger than window
       System.Console.SetWindowSize(122,54);   //set window size to almost full screen 
       //width - maxSet(127,57) (width, height)

       //System.Console.ResetColor(); //resets fore and background colors to default

   }  // End  setConsoleSize()

Quoted from the post: "My maximum console size that I could use was 127 columns and 57 rows because that's all that my screen resolution will allow. Reset your screen resolution and this will change.

This is just one of those things that you are going to have to play around with in order for you to get it to display as you like. "

DeveloperDan
  • 4,626
  • 9
  • 40
  • 65
2

the

mode 

and

system("mode... 

solutions did not work for me and I could not set the layout without getting a access error.

Fix was to close Cygwin, right click properties on the icon in the start menu and edit layout -> window -> height and then say yes to allowing administrator privileges to save settings. (not run as administrator).

now when running Cygwin always gives me a large window.

Windows 7 64bit.

rob
  • 8,134
  • 8
  • 58
  • 68
1

Hey have you guys here ever thought of the possibility of launching and running Cygwin from within the windows command prompt/console? This is what I always do. Then you can do anything you want to the look of the console to make it sexy.

trying to get su from within cygwin can be difficult at times, especially when you are attempting to do some heavy crunching with the tools provided. People have tried all sorts of things from sudo SU for windows to what ever...when it can be as simple as passing on the administrator credentials from you the "user" (if you are the admin?) even without weird UAC pop ups. You can do this via a simple batch script. Have a below this of a screen grab of what my Cygwin looks like and this is running from a portable version of Cygwin too! No registry entries and any of that rubbish!
The batch file passes the credentials to bash and then bash changes directory (notice the double quotes are needed to pass this variable to the Cygwin colsole in order for it to work)

@echo off
setlocal enabledelayedexpansion
REM Changing working folder back to current directory
%~d0
CD %~dp0
REM Folder changed
bash --login -i -c "cd {insert_directory_name_here} && exec ./execution-file-here"
cls
exit 1

Note: the brackets like so { } in the above example are NOT included in the batch script. also note that windows CMD window is passing off the string to cygwin to interpret as multiple conditions; cygwin doesn't read the quotes them selves but whats between them. the && is saying change directories and when you do execute the script ./execution-file-here when you get there.

It's a double whammy you can launch a Cygwin or linux like application from within a MS-Windows window and not even type a letter of code or open a console or anything.

I keep this batch file inside of the /Cygwin/bin directory and create a Windows shortcut link on the desktop. Within the shortcut I can stylise the cmd shell window. Even go as far as transparency ;-)

enter image description here

enter image description here

Jon Lin
  • 142,182
  • 29
  • 220
  • 220
James
  • 19
  • 1
1

To get all future console windows in a specific size you can create a shortcut to cmd.exe and then set size on the layout-tab of the shortcut properties.

sepang
  • 4,640
  • 4
  • 23
  • 23
1

In console properties at the Layout tab you can configure the following:

Screen Buffer Size Width

Window Size Width

The Window Size Width is how many characters per line will be visible. The Screen Buffer Size is the size of the line. If you set for example the Window Size Width at 100 and the Screen Buffer Size Width at 200, you will need to use the scrollbar to view the whole contents of lines with sizes between 100 and 200. Lines longer than 200 characters will appear in more than one line. This is useful if you have long lines and you want to copy them in a text file.

The same things apply for Windows PowerShell

kgiannakakis
  • 103,016
  • 27
  • 158
  • 194
0

Click on the icon on the top left of the console frame (the one that looks like "C:\"), then select Properties . This lets you customize all kinds of stuff. The "layout" tab has the width of the window.

Galghamon
  • 2,012
  • 18
  • 27
0

Use SetConsoleScreenBufferSize(HANDLE hConsoleOutput, coord dwSize) from windows.h