Published in Articles on by Michiel van Oosterhout ~ 5 min read
As we've learned in The Windows command-line interface, part 1 and part 2, since the earliest days of Windows NT the Console Window Host (conhost.exe
) has been the default application that Windows spawns and connects to command-line programs. Console Window Host can be configured via the Windows Registry and via the shortcut files (.lnk
) used to start command-line programs. Although most of use will probably switch to the new Windows Terminal app, some of you may still want to (or have to) continue using Console Window Host. So let's see how this application is configured.
Settings
As explained in Microsoft's Windows Command Line blog, the settings for Console Window Host are persisted to, and loaded from, multiple locations, with a hierarchy to determine overriding behavior.
The default settings for Console Window Host are stored under the HKCU:\Console
key in the Windows Registry. Settings for specific command-line programs that are started directly from the Windows shell are stored under a subkey that matches the path to the command-line program's executable file. For example %SystemRoot%_System32_cmd.exe
for Windows Command Processor, and %SystemRoot%_System32_WindowsPowerShell_v1.0_powershell.exe
for Windows PowerShell. These settings override matching default settings.
When a command-line program is started via a shortcut (.lnk
file) then the settings that are stored in the shortcut apply. Shortcuts contain most of the settings (see NT_CONSOLE_PROPS
), so they also override most of the settings in the registry. The settings stored in a shortcut can only be changed programmatically via the IShellLinkDataList
interface, which is not easily accessed via a Windows PowerShell script.
The title of the dialog that is used to change the settings indicates where the changes will be persisted:

Saving settings to the Windows Registry
Microsoft enabled most of the new features it introduced in recent years, so the Windows PowerShell script below only changes a few additional settings.
# Declare the registry values to set
$values = @(
# Cursor Size: Large (100%)
@{ Name = "CursorSize"; Type = "DWord"; Value = 100; DisplayName = "Large cursor size" }
# Font: Cascadia Mono PL
@{ Name = "FaceName"; Type = "String"; Value = "Cascadia Mono PL"; DisplayName = "Cascadia Mono PL font" }
# Window Size: Width: 120, Height: 30 (stored as a Coordinate)
@{ Name = "WindowSize"; Type = "DWord"; Value = (30 * 65536) + 120; DisplayName = "Window size: 120x30" }
# Terminal Scrolling: Disable Scroll-Forward
@{ Name = "TerminalScrolling"; Type = "DWord"; Value = 1; DisplayName = "Disable scroll-forward" }
# Use Ctrl+Shift+C/V as Copy/Paste
@{ Name = "InterceptCopyPaste"; Type = "DWord"; Value = 1; DisplayName = "Ctrl+Shift copy/paste" }
)
# Ensure the registry key exists
$defaultsPath = "HKCU:\Console"
if (-not (Test-Path -Path $defaultsPath))
{
$key = New-Item -Force -ItemType Directory -Path $defaultsPath
}
# Delete the program-specific keys and values
Get-ChildItem -Path $defaultsPath | Remove-Item -Force -Recurse
# Force the (re)creation of the registry values
$values | ForEach-Object {
$displayName = $_.DisplayName
$name = $_.Name
$type = $_.Type
$value = $_.Value
Write-Host "Setting [$displayName]..." -NoNewline
$value = New-ItemProperty -Force -Name $name -Path $defaultsPath -PropertyType $type -Value $value
Write-Host " OK"
}
We already installed Cascadia Mono PL in an earlier article.
Recreating shortcuts to command-line programs
Because shortcuts to command-line programs override most of the settings in the registry, we should replace those shortcuts after changing the settings in the registry. Creating shortcuts in Windows PowerShell requires us to instantiate Windows Scripting Host's WshShell
COM object:
You create a WshShell object whenever you want to run a program locally, manipulate the contents of the registry, create a shortcut, or access a system folder.
The Windows PowerShell script below only recreates the shortcuts to the built-in command-line shells. If you have other command-line programs that you start via a shortcut, then you can add those to the script easily.
# Create the Shell's automation object
$shell = New-Object -ComObject "WScript.Shell"
# Define a list of shortcuts to command-line programs
$programs = @(
@{
Arguments = ""
Name = "Command Prompt"
Description = "Performs text-based (command-line) functions"
Path = "$Env:APPDATA\Microsoft\Windows\Start Menu\Programs\System Tools"
TargetPath = "$Env:SystemRoot\System32\cmd.exe"
WorkingDirectory = "%HOMEDRIVE%%HOMEPATH%"
}
@{
Arguments = "-NoLogo"
Name = "Windows PowerShell"
Description = "Performs object-based (command-line) functions"
Path = "$Env:APPDATA\Microsoft\Windows\Start Menu\Programs\Windows PowerShell"
TargetPath = "$Env:SystemRoot\System32\WindowsPowerShell\v1.0\powershell.exe"
WorkingDirectory = "%HOMEDRIVE%%HOMEPATH%"
}
)
# Recreate the shortcuts
$programs | ForEach-Object {
$name = $_.Name
$path = $_.Path
$path = "$(Join-Path -Path $path -ChildPath $name).lnk"
# Delete shortcut if it exists
If (Test-Path -Path $path)
{
Remove-Item -Force -Path $path
}
# Recreate shortcut
Write-Host "Recreating shortcut [$name]..." -NoNewline
$shortcut = $shell.CreateShortcut($path)
$shortcut.Arguments = $_.Arguments
$shortcut.Description = $_.Description
$shortcut.TargetPath = $_.TargetPath
$shortcut.WorkingDirectory = $_.WorkingDirectory
$shortcut.Save()
Write-Host " OK"
}
The script also adds options (/k cls
and -NoLogo
) to the shortcuts to remove the banners printed by these particular command-line shells.
Default host
Windows 11 22H2 (October 2022 update) makes the Windows Terminal app the default application that Windows spawns and connects to command-line programs.
This is a setting that is stored under the HKCU:\Console\%%Startup
key in the Windows Registry 1. The Windows PowerShell script below configures Console Window Host as the default.
# Ensure the registry key exists
$path = "HKCU:\Console\%%Startup"
if (-not (Test-Path -Path $path))
{
$key = New-Item -Force -ItemType Directory -Path $path
}
# Use Console Windows Host
$console = "{B23D10C0-E52E-411E-9D5B-C09FDF709C7D}"
# Make Console Window Host the default
Write-Host "Setting Console Window Host as the default host..." -NoNewline
$value = New-ItemProperty -Force -Name "DelegationConsole" -Path $path -PropertyType "String" -Value $console
$value = New-ItemProperty -Force -Name "DelegationTerminal" -Path $path -PropertyType "String" -Value $console
Write-Host " OK"
With this setting it's still possible to start Windows Terminal via the Start menu or taskbar.
Summary
Settings for Console Window Host are stored in the Windows Registry and in shortcuts. A consistent command-line interface requires the removal of program-specific settings from the registry, and recreation of shortcuts.