Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

start wt.exe with parameter fails in administrator mode #14861

Open
Matzeeee opened this issue Feb 16, 2023 · 5 comments
Open

start wt.exe with parameter fails in administrator mode #14861

Matzeeee opened this issue Feb 16, 2023 · 5 comments
Labels
Area-Commandline wt.exe's commandline arguments Help Wanted We encourage anyone to jump in on these. Issue-Bug It either shouldn't be doing this or needs an investigation. Priority-2 A description (P2) Product-Terminal The new Windows Terminal.
Milestone

Comments

@Matzeeee
Copy link

Windows Terminal version

1.16.230126001

Windows build number

10.0.19045.2604

Other Software

No response

Steps to reproduce

Open cmd.exe and type "wt ping google.de".
image

Expected Behavior

Open wt with cmd.exe and execute "ping google.de".
image

Actual Behavior

If wt runs with option "run profile as administrator" cmd.exe opens but parameter (ping google.de) is not executed.
image
image

@Matzeeee Matzeeee added Issue-Bug It either shouldn't be doing this or needs an investigation. Needs-Triage It's a new issue that the core contributor team needs to triage at the next triage meeting labels Feb 16, 2023
@zadjii-msft
Copy link
Member

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?
  • Or should it open unelevated?

I'd lean towards the second. Does that make sense to you @Matzeeee?


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.

@zadjii-msft zadjii-msft added Product-Terminal The new Windows Terminal. Priority-2 A description (P2) and removed Needs-Triage It's a new issue that the core contributor team needs to triage at the next triage meeting labels Feb 16, 2023
@zadjii-msft zadjii-msft added this to the Terminal v1.18 milestone Feb 16, 2023
@microsoft-github-policy-service microsoft-github-policy-service bot added Needs-Tag-Fix Doesn't match tag requirements labels Feb 16, 2023
@Matzeeee
Copy link
Author

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?
  • Or should it open unelevated?

I'd lean towards the second. Does that make sense to you @Matzeeee?

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.

@microsoft-github-policy-service microsoft-github-policy-service bot added the Needs-Triage It's a new issue that the core contributor team needs to triage at the next triage meeting label Feb 16, 2023
@carlos-zamora carlos-zamora added Area-Commandline wt.exe's commandline arguments and removed Needs-Triage It's a new issue that the core contributor team needs to triage at the next triage meeting Needs-Tag-Fix Doesn't match tag requirements labels Feb 22, 2023
@zadjii-msft
Copy link
Member

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.

@zadjii-msft zadjii-msft added the Help Wanted We encourage anyone to jump in on these. label Oct 4, 2023
@zadjii-msft zadjii-msft modified the milestones: Terminal v1.19, Backlog Oct 4, 2023
@Matzeeee
Copy link
Author

will this ever be fixed?

@lhecker
Copy link
Member

lhecker commented Dec 17, 2024

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:

Image

I'll keep this tab open and look into it after the holidays.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Commandline wt.exe's commandline arguments Help Wanted We encourage anyone to jump in on these. Issue-Bug It either shouldn't be doing this or needs an investigation. Priority-2 A description (P2) Product-Terminal The new Windows Terminal.
Projects
None yet
Development

No branches or pull requests

4 participants