Repository: microsoft/terminal (language: cpp)

Issue:
Group Policy to control default Terminal setting
Since a year or longer I can choose if WT is the default conhost.

Is it possible to implement a policy that allows company admins to control this centralized?


Discussion / hints:
Right now, enterprise administrators can use Group Policy to roll out registry changes as documented in [this knowledgebase article](https://support.microsoft.com/en-us/windows/command-prompt-and-windows-powershell-for-windows-11-6453ce98-da91-476f-8651-5c14d5777c20).

Fix patch:
diff --git a/policies/WindowsTerminal.admx b/policies/WindowsTerminal.admx
index 48c36aec7eb..47c2f981bb1 100644
--- a/policies/WindowsTerminal.admx
+++ b/policies/WindowsTerminal.admx
@@ -9,6 +9,7 @@
   <supportedOn>
     <definitions>
       <definition name="SUPPORTED_WindowsTerminal_1_21" displayName="$(string.SUPPORTED_WindowsTerminal_1_21)" />
+      <definition name="SUPPORTED_DefaultTerminalApplication" displayName="$(string.SUPPORTED_DefaultTerminalApplication)" />
     </definitions>
   </supportedOn>
   <categories>
@@ -24,5 +25,61 @@
         <multiText id="DisabledProfileSources" valueName="DisabledProfileSources" required="true" />
       </elements>
     </policy>
+    <policy name="DefaultTerminalApplication" class="User" displayName="$(string.DefaultTerminalApplication)" explainText="$(string.DefaultTerminalApplicationText)" presentation="$(presentation.TermAppSelection)" key="Console\%%Startup">
+      <parentCategory ref="WindowsTerminal" />
+      <supportedOn ref="SUPPORTED_DefaultTerminalApplication" />
+      <elements>
+        <enum id="TermAppSelect" required="true" valueName="DelegationTerminal">
+          <item displayName="$(string.TermAppAutomatic)">
+            <value>
+              <string>{00000000-0000-0000-0000-000000000000}</string>
+            </value>
+            <valueList>
+              <item key="Console\%%Startup" valueName="DelegationConsole">
+                <value>
+                  <string>{00000000-0000-0000-0000-000000000000}</string>
+                </value>
+              </item>
+            </valueList>
+          </item>
+          <item displayName="$(string.TermAppConsoleHost)">
+            <value>
+              <string>{B23D10C0-E52E-411E-9D5B-C09FDF709C7D}</string>
+            </value>
+            <valueList>
+              <item key="Console\%%Startup" valueName="DelegationConsole">
+                <value>
+                  <string>{B23D10C0-E52E-411E-9D5B-C09FDF709C7D}</string>
+                </value>
+              </item>
+            </valueList>
+          </item>
+          <item displayName="$(string.TermAppWindowsTerminal)">
+            <value>
+              <string>{E12CFF52-A866-4C77-9A90-F570A7AA2C6B}</string>
+            </value>
+            <valueList>
+              <item key="Console\%%Startup" valueName="DelegationConsole">
+                <value>
+                  <string>{2EACA947-7F5F-4CFA-BA87-8F7FBEEFBE69}</string>
+                </value>
+              </item>
+            </valueList>
+          </item>
+          <item displayName="$(string.TermAppWindowsTerminalPreview)">
+            <value>
+              <string>{86633F1F-6454-40EC-89CE-DA4EBA977EE2}</string>
+            </value>
+            <valueList>
+              <item key="Console\%%Startup" valueName="DelegationConsole">
+                <value>
+                  <string>{06EC847C-C0A5-46B8-92CB-7C92F6E35CD5}</string>
+                </value>
+              </item>
+            </valueList>
+          </item>
+        </enum>
+      </elements>
+    </policy>
   </policies>
 </policyDefinitions>
diff --git a/policies/en-US/WindowsTerminal.adml b/policies/en-US/WindowsTerminal.adml
index 5516292e123..f2bcf71d3c3 100644
--- a/policies/en-US/WindowsTerminal.adml
+++ b/policies/en-US/WindowsTerminal.adml
@@ -7,6 +7,7 @@
     <stringTable>
       <string id="WindowsTerminal">Windows Terminal</string>
       <string id="SUPPORTED_WindowsTerminal_1_21">At least Windows Terminal 1.21</string>
+      <string id="SUPPORTED_DefaultTerminalApplication">At least Windows 11 22H2 or Windows 10 22H2 (Build 19045.3031, KB5026435) with Windows Terminal 1.17</string>
       <string id="DisabledProfileSources">Disabled Profile Sources</string>
       <string id="DisabledProfileSourcesText">Profiles will not be generated from any sources listed here. Source names can be arbitrary strings. Potential candidates can be found as the "source" property on profile definitions in Windows Terminal's settings.json file.
 
@@ -18,11 +19,22 @@ Common sources are:
 For instance, setting this policy to Windows.Terminal.Wsl will disable the builtin WSL integration of Windows Terminal.
 
 Note: Existing profiles will disappear from Windows Terminal after adding their source to this policy.</string>
+      <string id="DefaultTerminalApplication">Default terminal application</string>
+      <string id="DefaultTerminalApplicationText">Select the default terminal application used in Windows.
+
+If you select Windows Terminal Preview and it is not installed the system will fallback to the legacy Windows Console Host. (Please note that the settings interfaces showing "Let windows decide" in this case as configuration.)</string>
+      <string id="TermAppAutomatic">Automatic selection (Windows Terminal, if available)</string>
+      <string id="TermAppConsoleHost">Windows Console Host (legacy)</string>
+      <string id="TermAppWindowsTerminal">Windows Terminal</string>
+      <string id="TermAppWindowsTerminalPreview">Windows Terminal Preview (if available)</string>
     </stringTable>
     <presentationTable>
       <presentation id="DisabledProfileSources">
         <multiTextBox refId="DisabledProfileSources">List of disabled sources (one per line)</multiTextBox>
       </presentation>
+      <presentation id="TermAppSelection">
+        <dropdownList refId="TermAppSelect" noSort="true" defaultItem="0">Select from the following options:</dropdownList>
+      </presentation>
     </presentationTable>
   </resources>
 </policyDefinitionResources>


Test patch: