Repository: microsoft/terminal (language: cpp)

Issue:
DefTerm + elevate by default does not work AT ALL
### Windows Terminal version

1.13.10336.0

### Windows build number

10.0.22543.1000

### Other Software

_No response_

### Steps to reproduce

![image](https://user-images.githubusercontent.com/85196642/152552528-981303c8-940b-4ee5-91d6-59bb8e41949a.png)
1. Default Terminal Application: Windows Terminal Preview
2. Defaults profile - Run this profile as administrator automatically
-
Now run Command Prompt (cmd.exe)

### Expected Behavior

Only Windows Terminal should open when its set as default and set to run as administrator on launch.

### Actual Behavior

When opening Command Prompt and having Terminal run as admin by default first asks for UAC so it can open and then old cmd.exe opens in the background with Terminal being unresponsive and only way of being able to close it is with Task Manager
![image](https://user-images.githubusercontent.com/85196642/152551703-35fe9dac-d913-4f87-9d87-592666958b7e.png)
![image](https://user-images.githubusercontent.com/85196642/152551796-e7f6b3ba-4e35-4c63-bddb-4650eda8dfd6.png)




Discussion / hints:

Fix patch:
diff --git a/src/cascadia/TerminalApp/TerminalPage.cpp b/src/cascadia/TerminalApp/TerminalPage.cpp
index 91f6e9f8b0e..9b08ba85052 100644
--- a/src/cascadia/TerminalApp/TerminalPage.cpp
+++ b/src/cascadia/TerminalApp/TerminalPage.cpp
@@ -3095,9 +3095,12 @@ namespace winrt::TerminalApp::implementation
         {
             NewTerminalArgs newTerminalArgs;
             newTerminalArgs.Commandline(connection.Commandline());
-            const auto profile{ _settings.GetProfileForArgs(newTerminalArgs) };
-            const auto settings{ TerminalSettings::CreateWithProfile(_settings, profile, *_bindings) };
-
+            // GH #12370: We absolutely cannot allow a defterm connection to
+            // auto-elevate. Defterm doesn't work for elevated scenarios in the
+            // first place. If we try accepting the connection, the spawning an
+            // elevated version of the Terminal with that profile... that's a
+            // recipe for disaster. We won't ever open up a tab in this window.
+            newTerminalArgs.Elevate(false);
             _CreateNewTabFromPane(_MakePane(newTerminalArgs, false, connection));
 
             // Request a summon of this window to the foreground
diff --git a/src/cascadia/TerminalSettingsModel/ActionArgs.idl b/src/cascadia/TerminalSettingsModel/ActionArgs.idl
index b3d0d5d3d94..ddc05c28dc9 100644
--- a/src/cascadia/TerminalSettingsModel/ActionArgs.idl
+++ b/src/cascadia/TerminalSettingsModel/ActionArgs.idl
@@ -130,7 +130,7 @@ namespace Microsoft.Terminal.Settings.Model
         String ColorScheme;
         // This needs to be an optional so that the default value (null) does
         // not modify whatever the profile's value is (either true or false)
-        Windows.Foundation.IReference<Boolean> Elevate { get; };
+        Windows.Foundation.IReference<Boolean> Elevate;
 
         Boolean Equals(NewTerminalArgs other);
         String GenerateName();


Test patch: