Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

The application I want to start is MongoDB. If I would start it normally, it looks like this:

enter image description here

I don't like the amount of line breaks and I have a lot of screen space, so I would like to utilize said space to get rid of the line breaks.

I can change the size of the console window with MODE, so I wrote a batch file like this:

MODE con:cols=140 lines=70
%~dp0mongodb\bin\mongod --dbpath %~dp0data --rest

So far, so good. When I start this batch file, I get a larger window, as desired.

But when I now press Ctrl+C to exit MongoDB, I get the annoying prompt:

Terminate batch job (Y/N)?

Which is useless, because the command I just exited out of was the last command in the batch job anyway and no matter what I answer, the result is the same.

So, how can I get a larger console window for the application without having that prompt when I hit Ctrl+C?

share|improve this question

5 Answers 5

up vote 7 down vote accepted

I spent a few hours today to implement a small C# application that can wrap another console application and adjust the window size of the console host.

console-wrapper is easy to use. It only expects a couple of command line parameters:

Usage: console-wrapper.exe [OPTIONS]


      --subject=VALUE        The application that should be started by the
                               console wrapper.
      --width=VALUE          The desired width of the console window.
      --height=VALUE         The desired height of the console window.
  -h, -?, --help             Shows this help message

--width and --height are used to set the size of the resulting console window. --subject can be used optionally, if it is omitted, the remaining parameters are treated as the command (with parameters) to start.

So the final call I'm using now in our startup script is:

START "MongoDB" database\console-wrapper.exe --width=140 --height=70 %~dp0database\mongodb\bin\mongod.exe --dbpath %~dp0database\data --rest

The resulting window will have the requested size and upon hitting Ctrl+C, the window will close (after having properly shut down the contained process).

share|improve this answer

As far as I understand the question, you want MongoDB to have the specified size of console window and to exit when you press Ctrl+C. Then the answer is pretty simple: use shortcut to start it.

I don't have mongod executable, so I would use perl.exe as an example. When you start it from Run dialog (Windows+R), the size of the console window would be standard 80×25 with buffer size for 300 lines.

  1. Create a shortcut to mongod (or perl in my case).
  2. Right-click the shortcut and click Properties.
    1. On Shortcut tab in Target field, add parameters to mongod.
    2. Start in field controls the initial current directory of the started program. By default it will be the directory where .exe is located.
  3. Click Layout tab.
    1. Change Window size to 140×70.
      Shortcut properties, Layout tab
    2. You can increase the Height of Screen buffer size to 1000 or more to be able to scroll up to older messages.
    3. If you clear Let system position window, you can specify the location of the console window on the screen.
  4. Click OK to close shortcut properties.

Now when you click this shortcut, the console window would be of the specified size. When you press Ctrl+C, the application exits and the window closes without any additional prompts.

You can also change the layout of the window after you launched it from Run dialog. Right-click the title of the console window and click Properties. Click Layout tab, adjust the window size and click OK to close the properties and to apply the changes immediately. (If the window was started from shortcut, the properties of the shortcut are updated.)

The next time you start the same application, the size of the console window will be magically the same size. (I haven't checked it this time but it used to work.)

share|improve this answer
The location of mongod.exe is not fixed. It will change depending on the deployment of the application. Which is why I was aiming for a solution through the console directly. When I put a relative path in the target or working directory fields for a shortcut, it won't accept them :( –  Oliver Salzburg Oct 3 '13 at 18:14
@OliverSalzburg Did you try the approach of re-starting the batch? I mean your batch starts itself via start cmd /k and passes an additional parameter or sets an environment variable. The second instance then changes console window size and starts mongod.exe. –  Alexey Ivanov Oct 3 '13 at 18:29
Yes, I tried a lot of things. But as long as there is a batch file involved, the solution will suffer from the Terminate batch job (Y/N)? prompt :\ I actually just finished implementing a wrapper application to solve this for me though. –  Oliver Salzburg Oct 3 '13 at 18:48
@OliverSalzburg It will be a very useful utility. I also thought a wrapper would be the only way… –  Alexey Ivanov Oct 6 '13 at 7:10

Have you considered running it from a powershell script? Powershell is capable of resizing it's own window

$h = Get-Host
$buf = $h.UI.RawUI.BufferSize
$buf.Width = 300
$h.ui.rawui.BufferSize = $buf
$win = $h.UI.RawUI.WindowSize
$win.Width = 150
$h.ui.rawui.WindowSize = $win
#Command to start mongodb here.

This creates a window with a size of 150 but also has a sideways scrollable buffer of 300.

share|improve this answer
Yeah, I did consider it, but didn't know how to implement it at the time. This works perfectly, except for the slight annoyance that execution of scripts might possible be disabled. –  Oliver Salzburg Oct 3 '13 at 18:46

The default console layout settings live here in the registry:


You can modify these settings and they will apply to ALL command windows that launch, regardless of the path. Unfortunately, the raw values are not human friendly.

To set them the way you want them, open a regular cmd window, then edit the settings to your liking. Look in the registry at the above path and you should see a sub key under "Console" for cmd.exe. Export that key to a file, change the path to the above and import, or just manually copy the values from one to the other. You can then delete the cmd.exe specific entry. Now, all command windows that open will use the modified defaults.

I've found it handy to create a couple of registry entry files with my standard defaults so that I can easily pop them onto a new server when I RDP in for the first time. I made presets for the two sizes I typically use.

For 1024 x 768 (I use this for servers normally accessed via a multi session RDP tool):

Windows Registry Editor Version 5.00


For 1280 x 1024:

Windows Registry Editor Version 5.00

share|improve this answer

Put the Start command in front of calling mongodb. I believe that should fix it.

share|improve this answer
No, that opens MongoDB in a new console window. When I use start /b it will leave the console window open after I press Ctrl+C. –  Oliver Salzburg Oct 2 '13 at 16:25

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.