Controlling the Forced Use of Windows Terminal: A ForceV2 Configuration Guide

Controlling the Forced Use of Windows Terminal: A ForceV2 Configuration Guide
Photo by Athul Cyriac Ajay / Unsplash

Hello!

On recent Windows 10/11 systems, Windows Terminal launches automatically in place of the classic Command Prompt. The setting that controls this behavior is called "ForceV2". In this article, we take a close look at ForceV2 and how to configure it.

[Note] This article deals with registry operations. Registry changes must be made carefully, and incorrect operations can affect your system. We recommend backing up your system before proceeding. The content of this article is provided for general informational purposes, and behavior may differ depending on your environment. Please perform these operations at your own discretion and responsibility.

What is ForceV2?

ForceV2 is a value managed in the Windows registry that controls how the Command Prompt behaves

  • Value 1 (default): the new Windows Terminal is used
  • Value 0: the classic console (conhost.exe) is used

This setting lives at the following registry path

HKEY_CURRENT_USER\Console

Why would you change ForceV2?

Windows Terminal offers many excellent features, but there are cases where the classic Command Prompt is needed:

  1. Compatibility issues with certain legacy applications
  2. Debugging custom console applications
  3. Cases where certain console features do not work correctly in the new terminal

⚠️ Caution: with WSL, your existing batch files may stop working (there is a fix)

If you set ForceV2 to 0 (using the legacy console), a problem occurs when using WSL:

The problem

When you try to launch WSL from a batch file, the following error appears:

Unsupported console settings. In order to use this feature the legacy console must be disabled.

Error code: Wsl/Service/WSL_E_CONSOLE

Why this happens

  • WSL depends on features of the new Windows Terminal/ConPTY
  • In particular, it needs the following
    • Improved Unicode support
    • Modern terminal emulation
    • Special console features for WSL

How to fix it

  1. Recommended approach: set ForceV2 to 1
reg add "HKEY_CURRENT_USER\Console" /v ForceV2 /t REG_DWORD /d 1 /f
  1. Alternative: launching WSL directly from Windows Terminal works fine (though for WSL users who want to script things in batch files, that rather defeats the purpose)

In environments that use WSL, we generally recommend keeping ForceV2 set to 1 (enabled). This gives you

  • WSL working correctly
  • Access to the latest terminal features
  • Improved rendering of Unicode characters
  • A better overall development experience

How to configure it

Method 1: Batch file (the easiest)

Create a batch file (.bat) with the following content.

To use the classic Command Prompt (disable ForceV2)

reg add "HKEY_CURRENT_USER\Console" /v ForceV2 /t REG_DWORD /d 0 /f

To use Windows Terminal (enable ForceV2)

reg add "HKEY_CURRENT_USER\Console" /v ForceV2 /t REG_DWORD /d 1 /f

Method 2: Configure it from a C# program

If you need more flexible control, doing it in C# works well too

using (RegistryKey key = Registry.CurrentUser.CreateSubKey(@"Console"))
{
    // Disable (0) or enable (1) ForceV2
    key.SetValue("ForceV2", 0, RegistryValueKind.DWord);
}

Method 3: Set it manually in Registry Editor

  1. Press Windows key + R and type "regedit"
  2. HKEY_CURRENT_USER\ConsoleNavigate to
  3. Right-click and choose New → DWORD (32-bit) Value
  4. Name it "ForceV2"
  5. Set the value to 0 or 1

How to verify the setting

To confirm the setting has been applied correctly

  1. After changing the setting, close all Command Prompt windows
  2. Open a new Command Prompt
  3. You can tell from the window's title bar and appearance

Notes

  • This is a per-user setting (HKEY_CURRENT_USER)
  • Administrator privileges are not required
  • The change applies to newly opened Command Prompt windows
  • Windows that are already open are not affected

Summary

The ForceV2 setting is an important way to customize the Windows console environment, but WSL users are best off keeping it set to 1 (enabled).

When developing or debugging, switching between the classic Command Prompt and the new Windows Terminal as needed should make your work that much more efficient

Read more