Saturday 3 September 2016

Change the WinPE console font/size/position/minimize/hide, using the SetConsole utility

When running scripts, etc. using the Windows console terminal window, you often want to change it's appearance. To change the size of the window, we can use a command such as:

mode con: cols=160 lines=60

However, changing the font that is used, especially if running WinPE, is a lot more tricky, especially as we cannot reboot after changing the registry.

Whilst looking for a solution, I found the handy SetConsole utility.

Usually, terminal and lucida fonts are always available (and also consolas in some later Windows OS's).

The primary things SetConsole.exe can do are:
  1. Change the font type and size (doesn't work for XP apparently)
  2. Enlarge the window without making it too large
  3. Placement of the window on the desktop, including moving to another display in a multi-display system
  4. Set buffer sizes
  5. Enable Quick Edit mode
  6. Minimise the console, bring it to foreground (or even hide it completely)
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, if present.

SetConsole works under WinPE. There are 32-bit and 64-bit versions, so you need to run the correct one. It also can also retrieve some useful information like /title for current and original console title, or use  /status for all the console information including a list of supported fonts, window size, position, number of monitors, etc.

setconsole max-10 tr     = set console to maximum size minus 10 lines and 10 characters wide, and at top-right position on screen.

Together with the standard Windows color command, we now have much better control over a terminal window!

We can even completely  hide the console (useful for Rubber Ducky covert scripts?).

No comments:

Post a Comment