terminal icon indicating copy to clipboard operation
terminal copied to clipboard

Run as administrator profiles do not run until terminal is ran as administrator.

Open SomeDudex64 opened this issue 3 years ago • 6 comments
trafficstars

Windows Terminal version

1.14.1963.0

Windows build number

10.0.22000.832

Other Software

No response

Steps to reproduce

  1. Log in to windows as a standard user without administrative permissions
  2. Create a new profile and configure it to run as administrator.
  3. Save the settings and try to run the profile

Expected Behavior

When the profile is ran under the standard non-admin account, the system should prompt the user for administrator credentials. Once the credentials are entered, the profile should run in a new windows with administrator permissions.

Actual Behavior

After entering credentials to the user account control prompt, the profile does not run. Instead it's execution (and appearance of its windows) is delayed until a new instance of terminal is ran as administrator.

This issue does not affect administrator accounts, it only occurs for accounts that are not in the administrators group.

SomeDudex64 avatar Aug 04 '22 18:08 SomeDudex64

Instead it's execution (and appearance of its windows) is delayed until a new instance of terminal is ran as administrator.

Wait like, a new window for the Terminal doesn't just open itself? And you need to go manually start the Terminal as admin, and when you do that, the previously requested elevated profile also launches? That's super weird.

Could you share your settings.json file/?

zadjii-msft avatar Aug 04 '22 22:08 zadjii-msft

Sure, here it is. settings.zip

SomeDudex64 avatar Aug 05 '22 08:08 SomeDudex64

Btw, if you run Windows Terminal as an Admin on a non-Admin account on the newest Dev Windows Insider preview build as of this moment (25174.1010) it just won't work 😂😳

SpyassL avatar Aug 09 '22 13:08 SpyassL

settings, without schemes
{
    "$help": "https://aka.ms/terminal-documentation",
    "$schema": "https://aka.ms/terminal-profiles-schema",
    "actions": 
    [
        {
            "command": 
            {
                "action": "copy",
                "singleLine": false
            },
            "keys": "ctrl+c"
        },
        {
            "command": "paste",
            "keys": "ctrl+v"
        },
        {
            "command": "find",
            "keys": "ctrl+shift+f"
        },
        {
            "command": 
            {
                "action": "splitPane",
                "split": "auto",
                "splitMode": "duplicate"
            },
            "keys": "alt+shift+d"
        }
    ],
    "alwaysShowNotificationIcon": true,
    "copyFormatting": "none",
    "copyOnSelect": false,
    "defaultProfile": "{0caa0dad-35be-5f56-a8ff-afceeeaa6101}",
    "profiles": 
    {
        "defaults": 
        {
            "experimental.retroTerminalEffect": true,
            "useAcrylic": true
        },
        "list": 
        [
            {
                "colorScheme": "Campbell Powershell",
                "cursorShape": "filledBox",
                "experimental.retroTerminalEffect": true,
                "guid": "{61c54bbd-c2c6-5271-96e7-009a87ff44bf}",
                "hidden": false,
                "name": "Windows PowerShell",
                "useAcrylic": true
            },
            {
                "colorScheme": "Vintage",
                "cursorShape": "underscore",
                "experimental.retroTerminalEffect": true,
                "guid": "{0caa0dad-35be-5f56-a8ff-afceeeaa6101}",
                "hidden": false,
                "name": "Command Prompt",
                "opacity": 50,
                "padding": "8"
            },
            {
                "colorScheme": "Solarized Dark",
                "experimental.retroTerminalEffect": true,
                "guid": "{b453ae62-4e3d-5e58-b989-0a998ec441b8}",
                "hidden": false,
                "name": "Azure Cloud Shell",
                "source": "Windows.Terminal.Azure",
                "useAcrylic": true
            },
            {
                "cursorShape": "emptyBox",
                "experimental.retroTerminalEffect": true,
                "guid": "{58ad8b0c-3ef8-5f4d-bc6f-13e4c00f2530}",
                "hidden": true,
                "name": "Debian",
                "source": "Windows.Terminal.Wsl",
                "useAcrylic": true
            },
            {
                "colorScheme": "One Half Dark",
                "commandline": "%windir%\\py.exe",
                "experimental.retroTerminalEffect": true,
                "guid": "{6459c186-a8e1-4185-91df-ab3fac03383e}",
                "icon": "C:\\Windows\\py.exe,0",
                "name": "Python 3.9",
                "tabTitle": "Python 3.9 Interpreter",
                "useAcrylic": true
            },
            {
                "guid": "{330eddfb-6ba7-562d-b414-f8bb158e0397}",
                "hidden": false,
                "name": "Developer Command Prompt for VS 2022",
                "source": "Windows.Terminal.VisualStudio"
            },
            {
                "guid": "{dc6bfe40-35f4-5de7-b308-60f79c5e3d2f}",
                "hidden": false,
                "name": "Developer PowerShell for VS 2022",
                "source": "Windows.Terminal.VisualStudio"
            },
            {
                "altGrAliasing": true,
                "antialiasingMode": "grayscale",
                "closeOnExit": "graceful",
                "colorScheme": "Vintage",
                "commandline": "%SystemRoot%\\System32\\cmd.exe",
                "cursorHeight": 25,
                "cursorShape": "vintage",
                "elevate": true,
                "experimental.retroTerminalEffect": false,
                "font": 
                {
                    "face": "Source Code Pro",
                    "size": 12,
                    "weight": 990
                },
                "guid": "{6c1e9995-d63e-4ce5-9956-2daec99a88a7}",
                "hidden": false,
                "historySize": 9001,
                "icon": "ms-appx:///ProfileIcons/{0caa0dad-35be-5f56-a8ff-afceeeaa6101}.png",
                "name": "Command Prompt (Administrator)",
                "opacity": 50,
                "padding": "8",
                "snapOnInput": true,
                "startingDirectory": "C:\\",
                "useAcrylic": false
            },
            {
                "altGrAliasing": true,
                "antialiasingMode": "grayscale",
                "closeOnExit": "graceful",
                "colorScheme": "Vintage",
                "commandline": "%SystemRoot%\\System32\\cmd.exe",
                "cursorShape": "underscore",
                "elevate": true,
                "experimental.retroTerminalEffect": true,
                "font": 
                {
                    "face": "Cascadia Mono",
                    "size": 12
                },
                "guid": "{ebd04fa3-78ce-434c-8149-67a3994032b8}",
                "hidden": false,
                "historySize": 9001,
                "icon": "ms-appx:///ProfileIcons/{0caa0dad-35be-5f56-a8ff-afceeeaa6101}.png",
                "name": "Command Prompt (Copy)",
                "opacity": 50,
                "padding": "8",
                "snapOnInput": true,
                "startingDirectory": "%USERPROFILE%"
            }
        ]
    },

    "tabWidthMode": "titleLength",
    "useAcrylicInTabRow": true
}

Nothing too interesting other than just the "elevate": true, CMD profile. Hmm. Maybe this is something weird with the app catalog.

zadjii-msft avatar Aug 12 '22 12:08 zadjii-msft

As I understand it, the problem is directly related to the crash. If a program tries to run an elevated instance, a dump is created. If the same command is executed in the system (run menu), then the profile is launched. WindowsTerminal_dmp.zip settings.zip "C:\Program Files\WindowsApps\Microsoft.WindowsTerminal_1.16.10232.0_x64__8wekyb3d8bbwe\WindowsTerminal.exe" --profile "{8f569650-577b-4062-9904-b4036d680942}"

iDolmatov avatar Jan 26 '23 03:01 iDolmatov

Maybe the elevation code through elevate-shim.exe isn't good enough. I ran this program directly with elevated rights to the TrustedInstaller level (system profile), on behalf of System. I also got a program crash. The user does not have rights to run elevate-shim.exe, so he artificially elevated the rights with a third-party program. It successfully launches directly an elevated terminal (with UAC) without requiring administrator privileges at startup. The test shows that elevating the rights to the system level causes the terminal to crash.

"C:\Program Files\WindowsApps\Microsoft.WindowsTerminal_1.16.10232.0_x64__8wekyb3d8bbwe\elevate-shim.exe"
 new-tab --profile "{8f569650-577b-4062-9904-b4036d680942}"

As far as I understand, such a launch raises the rights above UAC, tk. access to this program is required. This "breaks" the launch of the terminal.

iDolmatov avatar Jan 26 '23 04:01 iDolmatov