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 SetConsole.zip 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 SetConsole_x64.zip. The 64-bit version is named the same, but to keep it separate on the website it was put into a zip file named SetConsole_x64.zip. 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 v188.8.131.52 Copyright (C) 2013 from ScriptBasicHelper v184.108.40.206 32-bit by StefanOz.com Usage: 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 /pos[:cc|c|bc|cb|tc|ct|cr|rc|cl|lc|tr|rt|tl|lt|br|rb|bl|lb] /pos[:cx|xc|cy|yc|t|b|l|r] /pos[+x][-x][+t][-t][+w][-w][+h][-h] /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] Notes: 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. License: 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. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. Description: 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 right. /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) :w,h :facename,w,h[,i] (ineffective in Windows XP) :i 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. Examples: 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