Aug 182013

I created a program compiled in Microsoft Visual C 2010 to control the Command Prompt window from the command line.  It is a friendly substitute for MODE CON [COLS=c] [LINES=n], and it’s intended audience is people that do a lot of command line work, like network system administrators.  The reason the program was compiled in C was so that it would not require any run-time DLLs.  It is a standalone executable that runs on 32-bit and 64-bit Windows XP, Windows Vista, Windows 7 and Windows 8.  It has also been tested on WinPE 3.0 and WinPE 5.0.  It has been tested in Remote Desktop, including with the “Use All My Monitors for the remote session” option with a Windows 7 Ultimate remote machine.  It fails with an access denied error on Windows 2000 because the program calls several system functions that were introduced with Windows XP.

SetConsole.exe does not require administrator privileges, but administrator privileges are required to put the program in a convenient place like C:\Windows or C:\Windows\System32.

On Windows 7 it can do things that are commonly done using the Properties option of the Command Prompt Alt-space menu, including changing the font.  The settings it makes are dynamic and for the current session only.  When the Properties dialog of a Command Prompt window saves settings for a shortcut, they are written to the registry under HKCU\Console in a subkey named after the shortcut.  This will be discussed more in another post.

SetConsole.exe cannot change the keyboard rate or delay, and it does not change window colors.  To change the keyboard rate or delay from the command line, use MODE CON.  To change window colors in a script or from the command line, use the COLOR command.

The four primary things SetConsole.exe was created to do are 1) enlarge the window without making it too large like MODE CON.  2) Placement of the window on the desktop, including moving to another display in a multi-display system.  3) set buffer sizes.  4) Enable Quick Edit mode.

The /reset option sets the buffer height to a minimum of 1000, sets the buffer width to match the window width and enables quick edit mode.  Setting the buffer width to match the window width removes the horizontal scroll bar, which among other things, can be created by running WMIC and changing the window width before exiting.

To download a 32-bit SetConsole.exe, click and Save to your computer.  Then Extract the .exe file.  To be most convenient to you, you can copy SetConsole.exe to C:\Windows\System32 on 32-bit Windows.  On 64-bit Windows the appropriate place for the 32-bit version is C:\Windows\SysWOW64.  To download a 64-bit SetConsole.exe, click  The 64-bit version is named the same, but to keep it separate on the website it was put into a zip file named  The appropriate place for SetConsole.exe on 64-bit Windows is C:\Windows\System32 if you want it in your system path.  Alternatively, you can create a DOSKEY macro (aka alias) named something like SetCon and point it to anywhere you put the SetConsole.exe program.  The caveat with using a DOSKEY macro is that it needs to be recreated/defined every time you start a console window.

SetConsole.exe is free with a license based on the MIT license.

Below is the help display from SetConsole.exe /?:all

SetConsole.exe v1.0.0.4 Copyright (C) 2013
from ScriptBasicHelper v1.0.0.4 32-bit by
  SetConsole /w /h /bw /bh +x -x *x /x /size[+x][-x][*x][/x]
    /max[-x][*x][/x] /maxw[-x][*x][/x] /maxh[-x][*x][/x]
    /reset /resettobw
    /posx[-x][+x][-xT][+xT]] /posy[-x][+x][-xW][xW]
    /mc[:x,y] /m[:x] /m1 /m2 /m3 /m4 /std
    /qe[:+][:-] /InsMode[:+][:-]
    /fb[:+][:-] /font[:facename][:w,h][:facename,w,h[,i]][:i] +f -f
    /show[:PidOrTitle] /hide[:PidOrTitle] /min[:PidOrTitle] /fg[:PidOrTitle]
    /?[:section] /help /status[:detail] /showmode[:PidOrTitle] /title
    /largest /largestwidth /largestheight /list /getpid[:title] /version
    /window:title /process:processid /sleep[:secs]
      No switch is required.  Optional values are marked by [].
      Help sections are: Usage, License, Description, Size, Position,
      Edit, Font, Visibility, Info, Process, Examples.
      Available font facenames are shown by /status.

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.



SetConsole.exe is a substitute for MODE CON.  It was initially created
to maximize the console window without losing part of the window off
the left and bottom of the display.  A console window cannot be larger than
the monitor in which it is displayed, but the operating system can place
the window such that some of it is out of sight. Plus the operating system
calculates the maximum size without accounting for scroll bars.

SetConsole.exe can increase or decrease the display size and the font size.
It can move the console window, including to other monitors on a multiple
display system.

Switches/Options can be specified with slash (/), dash (-) or plus (+) prefix.
Capitalization is not significant.  Switch order is significant.  The last
option will be executed last.  For mode settings qe and InsMode, the +
and - prefixes are significant and enable or disable the mode.  The options
size, w, h, lines, cols, pos, posx, posy, max, maxw and maxh are special case
options and can be specified without a prefix character.

Window Size Options:
    /w : You can also use /width and /windowwidth.  This option sets the window
         width in characters.
    /h : You can also use /height and /windowheight.  This option sets the
         window height in characters.
    /bw : Same as /bufferwidth.  Set the buffer width.
    /bh : Same as /bufferheight.
    +x -x *x /x
    /size : The size option can be specified as a number prefixed by a math
            symbol (plus, minus, multiple, or divide).  The size option can
            also be specified as /size[+-*/]x where x is the number of
            characters of adjustment you want to make to the width and height
            of the console window.
    /std : Set the console window to standard size, 80x24.
    /max : Maximize the height and width of the console window.  If -x, *x or
           /x are specified then reduce the window by the specified amount.
           x can be fractional for *x.  In *x, if x is 2-9, or x is 20-90 then
           it is calculated as .20-.90.
    /maxw : Maximize the width and apply -x, *x, or /x.
    /maxh : Maximize the height and apply -x, *x, or /x.
    /reset : Reset the width of the buffer to match the window width so there
             no horizontal scroll bar.  Also sets Quick Edit mode and
             Insert Mode.
    /resettobw : Aliased to /reset2bw.  Same as /reset except the width of the
                 window is set as big as the buffer width.  This removes the
                 horizontal scroll bar like /reset does.
Window Position Options:
    /pos : Specify the window position as cc|c|bc|cb|tc|ct|cr|rc|cl|lc|tr|rt|
           tl|lt|br|rb|bl|lb|cx|xc|cy|yc|t|b|l|r where CBTRLXY are Center,
           Bottom, Top, Right, Left, X-axis, and Y-axis respectively.  The
           position indicators can be specified on the command line alone and
           will be treated as if they were prefixed with /pos:.  The T, W and
           H suffixes apply to /pos, /posx and /posy.  The T represents Title
           height as shown in /status:detail.  W represents font width and H
           represents font height.
    /posx : A more fine adjustment to horizontal position can be made with -x
            or +x where x is a number of pixels to move the window left or
    /posy : Adjust the window position by -x or +x where x is in pixels.
    /mc : Set window coordinates to Left and Top as x,y of the monitor.  This
          can also move the window to another monitor.
    /m : Move the the console window to monitor x, where x represents the
         display number listed by /status.
    /m1 : Move the console window to \\.\DISPLAY1.
    /m2 : Move the console window to \\.\DISPLAY2.
    /m3 : Move the console window to \\.\DISPLAY3.
    /m4 : Move the console window to \\.\DISPLAY4.
Edit Options:
    /qe : Display, Enable or Disable Quick Edit mode (related to select and
          copy operations).  Can also be specified as +qe and -qe.
    /InsMode : Display, Enable or Disable Insert mode.
Font Options:
    /fb : If the console font is TrueType font like Lucida or Consolas,
          bold the font with +fb and switch back to normal with -fb.
    /font : There are four forms for this switch:
            :facename (ineffective in Windows XP)
            :facename,w,h[,i]  (ineffective in Windows XP)
            All Windows Vista and 7 computers have Terminal and Lucida.
            Computers that have PowerPoint previewer or PowerPoint, also have
            Consolas.  The results you get when you experiment with :w,h, or
            :facename,w,h,i are too difficult to explain here.  If you find
            a facename,w,h combination that you like, you can use it.
            Otherwise results will be more friendly with +f and -f to change
            the font size.
            w and h are the width and height of the font.  i is the index
            number of the font which can be displayed with /status.  i is
            dynamic and not reliable between sessions.
    +f : Increase the font size in the current font.  This is unreliable in
         Windows XP.  In XP the font will switch between Terminal and TrueType
         fonts depending on what has already been selected in the menus, or if
         the window started in a TrueType font.
    -f : Decrease the font size in the current font.  Same restrictions as +f.

The font face cannot be changed by SetConsole in Windows XP.  The method for
having a console window in a different font face in XP, without using the menu,
has to be to open the window from a shortcut that specifies a different font,
which are actually settings in the registry.

Window Visibility Options:
    /show : Show the console window in Normal mode, the complement to /min.
    /hide : Careful.  This hides the console window and its taskbar icon.
            Only use /hide if you are sure the window will exit by itself,
            or it will be shown again programmatically.  The user can
            only unhide it with /window /show or /process /show.
    /min  : Minimize the window.  Aliased to /minimize
    /fg   : Aliased to /refocus /focus /foreground.  Attempt to set the
            console window as the foreground window.  If /window or /process
            are in effect, then the foreground operation is applied to the
            specified process.

Specify PidOrTitle to show, hide, minimize or refocus the console window with the
matching process Id or title.  Unlike /process or /window, following switches
apply to the original console window of the SetConsole program.

Info Options:
    /?, /help : Show help.  /?:section specifies a section to show.
                /?:all shows all sections.  The default is to show Usage and
                Examples.  Section names can be abbreviated.  All sections
                matching an abbreviation will be listed.
    /title : Show the title of the console window  It also shows the original
             title of the window before SetConsole.exe started.
             Set the title with the TITLE command.
    /list : List console window titles and process ids.  This provides
            process ids for /window and /process.  You can also specify
            /list:hidden, /list:all and /list:nonconsole.  Use "hidden" to list
            hidden console windows.  /list alone will only list visible
            console windows.  Use "all" to list all top level windows for
            the desktop.  Use "nonconsole" to list all windows with visible
            status that are not console windows.
    /getpid : Displays the (parent) Process Id of the process associated with the
              console window.  Specify :title to retrieve the same process
              Id that would be found by /window:title.
    /status : Output status information showing window size, font size and
              monitor sizes.  Specify /status:detail to get more details.
              SetConsole with no options lists status information similar
              to MODE CON.
    /largest : Also /L.  Display the largest width and height for the console
               in characters.
    /largestwidth : Also /LW or /largestw.  Display the largest width for the
                    console in characters.
    /largestheight : Also /LH or /largesth.  Display the largest height for
                     the console in characters.
    /showmode : Also /showm, displays window show mode like SW_MINIMIZED.
                Specify PidOrTitle to display the visibility mode of the
                console window with the matching process Id or title.
    /version : Also /v, displays the version of the program.

For the options /size, /pos, /posx, /posy, /mc, /m, /qe, /InsMode, /fb and
/font, if you don't specify a value, the appropriate parameter will
be displayed.  For /size, width and height will be displayed in characters.
For /pos and /mc, the Left and Top coordinates will be displayed.

Process Control Options:
    /window:title : Operate on the console window with the given title.
                    This will work for read only operations on processes
                    owned by another account, but will not work on processes
                    owned by another account for operations that change the
                    console.  Specify /window with no title to operate on the
                    process's default console window.
    /process:processid : Operate on the console attached to the given
                         processid.  Same restrictions as /window.  Specify
                         /process with no process id to operate on the
                         process's default console window.
    /sleep : Sleep for the given number of seconds.  The maximum time is
             24 hours (86400 seconds).  If no secs value is given the default
             is 1 second.  This option only affects the SetConsole.exe process.
             It does not affect processes specified with /window or /process.

    SetConsole max-10 br
    SetConsole /f:lucida
    SetConsole /f:10x17
    SetConsole +f h=47
    SetConsole +fb
    SetConsole -f
    SetConsole +20
    SetConsole +qe +insmode
    SetConsole max*9 /reset /pos:br
    SetConsole br-2T

  12 Responses to “Setconsole.exe Console Window control”

  1. Display number is fairly consistent in Windows, but there is a caveat to using the /m, /m2… switches. The number after the /m refers to the number from the device name \\.\DISPLAYn where n starts with 1. However, the second display is not always \\.\DISPLAY2, because on machines with two graphics adapters (card and motherboard integrated for example) the main graphics adapter could have two ports and only one monitor connected while the second graphics adapter has the second monitor. I have seen a case where the second monitor is consistently numbered as \\.\DISPLAY3. In that case, /m2 with SetConsole would have no effect and /m3 would be needed, or /mc, to switch from the first monitor to the second monitor. Note that the monitor device names are displayed with SetConsole /status.

  2. SetConsole.exe was updated today from v1.0.0.2 to v1.0.0.3. If /window or /process fails, then following arguments are ignored until another /window or /process is found on the command line. Naturally this is reset when SetConsole exits. If any command line options fail with an internal error code, the program exits with error code 1 instead of 0. If all command line options fail, the program exits with error code 2.

    posy-h was corrected so that it subtracts font height from the window position instead of adding it. Argument processing for /w:+10 was corrected so that it would not fail with an error message.

    t, b, L, r, xc, and yc were added to /pos.

    Enhancements to /list are planned for the next version.

  3. Hi, I would like to use your program in my project. to do that would like to know which type of license applies to your software. Which restriction applies.
    Thanks for your answer

  4. Hello Stefan,

    i was looking for a tool to control windows popup from a batch script process (Regina REXX on windows 7) and found your very valuable ‘SetConsole’ which works good.

    But I experienced a performance concern. The following command will use about 0,6 seconds to finish.

    address system “setconsole /process:”process_id” /show”

    Do you have any idea how this command can be accelerated ?

    Another question: I use the SetConsole to toggle a Window between ‘minimzed’ and ‘show’. How can I get the information about the current window status ?

    Greetings Wolfgang

    • The /process and /window switches were using the same function calls to retrieve the list of windows as were used in /list. However, /process and /window don’t need the ExeName, Owner and AdminStatus, so I modified the program to skip those fields for /process and /window. Now, the switches /process and /window are not dependent the WMI class Win32_Process, and avoiding queries to WMI speeds up the program. You might get the performance with v1.0.0.4 that you are expecting. With the previous version you could have gotten the window status with the following command:
      SetConsole /process:”process_id” /status |find /i “showmode”
      With v1.0.0.4 you can get the status with the following command:
      SetConsole /showmode:”process_id”

      • Stefan,

        thank you for your modifications on this great tool !

        I installed the new version and response time dropped from 0,6 to less than 0,1 seconds 🙂


  5. SetConsole.exe was updated today from v1.0.0.3 to v1.0.0.4. The help listing was broken into sections and /? shows Usage and Examples by default, a much shorter listing. Another important part of the update was adjustments to make SetConsole.exe work with Windows 8.1 in high DPI mode. The program uses SetProcessDPIAware() on Vista and higher to avoid problems. The program was modified to use fwprintf(stderr) instead of _cwprintf() because the console version of printf was not sending output reliably after consoles of other processes were attached and reattached. Minor changes were the addition of /showmode, /getpid and optional values for /show, /min and /hide. And the output of /list was shortened by leaving out WindowClass when listing only console windows.

  6. Also, /fg accepts a value for PidOrTitle like /show and /min. The algorithm to match a title for /getpid, /window, /show, /min, /hide and /fg finds the first exact match as a preference to finding the first match on the beginning of the title. That way, if you have two command windows started by the same shortcut and having the same title, /getpid will normally give the process id of the window not running SetConsole.exe.

  7. Thanks! 🙂

  8. Finally I found a great program for dos without high price of distribution.

    Thank so much!

  9. Really useful program for WinPE. I have blogged about it at

 Leave a Reply

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>