You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
start wt.exe with parameter fails in administrator mode #14861
Welp. Okay that's wacky, unexpected, and tricky to resolve.
Your profiles default is set to elevate:true (profiles.defaults, not just the profile that is your default).
When you do wt ping 8.8.8.8, the Terminal opens, and tries to run with all your profiles.default profile's settings, except with the commandline explicitly set to pint 8.8.8.8.
After evaluating the settings, Terminal determines this new tab should be run elevated (in accordance with your settings) and then ShellExectute's itself, passing in the profile it should use to spawn the new tab.
In this step, it does NOT pass that overwritten commandline along
The elevated terminal spawns, and just uses the default commandline for the profile it was told (which was just profiles.defaults)
This one's tricky. We basically need to pick something sensible to happen here. The argument could probably go either way:
Should the terminal open elevated, running ping 8.8.8.8?
In that case, we'd want to modify ShouldImmediatelyHandoffToElevated / _maybeElevate in TerminalPage to ensure that the commandline is the same as the profile, before we decide to just elevate.
In that case, we'd want to modify ShouldImmediatelyHandoffToElevated / _maybeElevate in TerminalPage to ensure that the commandline is the same as the profile, before we decide to just elevate.
I expected the terminal to start elevated and then execute the command.
You know, we might be able to something like #15286 for this. Pre-evaluate the actual commandline, given the NewTerminalArgs, and pass that in to elevate-shim.
I'd worry about escaping that commandline though. That'd be scary.
It seems it partially was fixed: wt pwsh now properly spawns PowerShell in an elevated tab. However, it seems something's wrong with parameter escaping, as mentioned above, because the entire commandline given to wt is passed as a "single argument string" that is interpreted as a command line path with spaces. Example:
I'll keep this tab open and look into it after the holidays.
Still reproducible on Windows Terminal 1.24.12741.0 (Windows 11, 10.0.26300), and I have a real-world trigger plus a process-creation log that shows exactly where the quoting gets mangled. It matches what a maintainer described in Dec 2024 in this thread: the whole command line reaches elevate-shim.exe as one quoted string and is then treated as an executable path containing spaces.
Setup:profiles.defaults.elevate is true (this is what makes a plain wt -- <command> go through the elevation path, as noted earlier in this thread).
Trigger: a third-party app (NetEase "UU Remote") launches a tab with an absolute, correctly quoted path:
The incoming command line is correctly quoted. By the time it is handed to elevate-shim.exe, the executable and all its arguments are wrapped in an extra pair of quotes, so the target becomes C:/Program + the rest.
Workaround that confirmed the cause for me: set profiles.defaults.elevate to false and add "elevate": true explicitly to the profiles that really need admin. After that the same launch works.
Activity
zadjii-msft commentedon Feb 16, 2023
Welp. Okay that's wacky, unexpected, and tricky to resolve.
elevate:true(profiles.defaults, not just the profile that is your default).wt ping 8.8.8.8, the Terminal opens, and tries to run with all yourprofiles.defaultprofile's settings, except with the commandline explicitly set topint 8.8.8.8.This one's tricky. We basically need to pick something sensible to happen here. The argument could probably go either way:
ping 8.8.8.8?I'd lean towards the second. Does that make sense to you M_a_t_z_e_ (@Matzeeee)?
In that case, we'd want to modify
ShouldImmediatelyHandoffToElevated/_maybeElevateinTerminalPageto ensure that the commandline is the same as the profile, before we decide to just elevate.Matzeeee commentedon Feb 16, 2023
I expected the terminal to start elevated and then execute the command.
zadjii-msft commentedon May 5, 2023
You know, we might be able to something like #15286 for this. Pre-evaluate the actual commandline, given the NewTerminalArgs, and pass that in to elevate-shim.
I'd worry about escaping that commandline though. That'd be scary.
Matzeeee commentedon Dec 16, 2024
will this ever be fixed?
lhecker commentedon Dec 17, 2024
It seems it partially was fixed:
wt pwshnow properly spawns PowerShell in an elevated tab. However, it seems something's wrong with parameter escaping, as mentioned above, because the entire commandline given towtis passed as a"single argument string"that is interpreted as a command line path with spaces. Example:I'll keep this tab open and look into it after the holidays.
wkin-t commentedon Oct 9, 2026
Still reproducible on Windows Terminal 1.24.12741.0 (Windows 11, 10.0.26300), and I have a real-world trigger plus a process-creation log that shows exactly where the quoting gets mangled. It matches what a maintainer described in Dec 2024 in this thread: the whole command line reaches
elevate-shim.exeas one quoted string and is then treated as an executable path containing spaces.Setup:
profiles.defaults.elevateistrue(this is what makes a plainwt -- <command>go through the elevation path, as noted earlier in this thread).Trigger: a third-party app (NetEase "UU Remote") launches a tab with an absolute, correctly quoted path:
Result: WT shows
0x80070002 (The system cannot find the file specified)forC:/Program "Files/Netease/GameViewer/bin/uuyc-cli.exe term ....Where it breaks (Security event 4688 with command-line auditing, same click, abridged):
The incoming command line is correctly quoted. By the time it is handed to
elevate-shim.exe, the executable and all its arguments are wrapped in an extra pair of quotes, so the target becomesC:/Program+ the rest.Workaround that confirmed the cause for me: set
profiles.defaults.elevatetofalseand add"elevate": trueexplicitly to the profiles that really need admin. After that the same launch works.Happy to test a fix or provide more logs.