Skip to content

'Use parent process directory' not being respected for new Tabs #14817

Open

Description

@EskimoRuler

Windows Terminal version

1.16.10262.0

Windows build number

10.0.2621.1105

Other Software

No response

Steps to reproduce

I have my WT setup so my default profile is lauch as admin and with the 'Use parent process directory' checked for starting directory. I then have all my other profiles set to 'Use parent process directory' for starting directory as well.

  1. Use the context menu to launch Windows Terminal from a folder.
  2. WT will launch default profile in the directory of the folder it was launch
  3. Opening a new Tab launches the new profile to the 'C:\Windows\System32' folder

Expected Behavior

Each new tab opened with different profiles should open in the same directory that WT was launched from

Actual Behavior

Each new tab is launch to the 'C:\Windows\System32' folder.

Activity

  1. added
    Issue-BugIt either shouldn't be doing this or needs an investigation.
    Needs-TriageIt's a new issue that the core contributor team needs to triage at the next triage meeting
    on Feb 9, 2023
  2. changed the title [-]'Use parent process directory' not being respected[/-] [+]'Use parent process directory' not being respected for new Tabs[/+] on Feb 9, 2023
  3. zadjii-msft commented on Feb 10, 2023

    @zadjii-msft
    Member

    Huh. I guess that makes sense, we're probably not passing the initial CWD of the Terminal to the elevate-shim to forward that to the elevated terminal instance.

    Note

    Walkthrough

    Probably wouldn't be terribly difficult to pass the original terminal's CWD to elevate-shim. I'd look at TerminalPage::_maybeElevate - that's where the handoff from an unelevated -> elevated process happens.

  4. added
    Help WantedWe encourage anyone to jump in on these.
    Area-UserInterfaceIssues pertaining to the user interface of the Console or Terminal
    and removed
    Needs-TriageIt's a new issue that the core contributor team needs to triage at the next triage meeting
    on Feb 10, 2023
  5. zadjii-msft commented on May 2, 2023

    @zadjii-msft
    Member

    Hmmmmmm.

    This almost looks like a dupe of #15173, but subtly different.

    With #15173, it's sufficient to just pass -d <path> to elevate-shim, to open the new tab in the requested directory.

    This however, requests that elevate-shim somehow communicates that the Terminal itself should set it's CWD. In this case, the auto-self-elevate case, we need to pass the current virtual directory of the terminal to the elevate shim, to pass to the new one. Ew. Almost like #4637

    I dunno if this regressed in 1.16 or was always broken.

  6. zadjii-msft commented on May 2, 2023

    @zadjii-msft
    Member

    There's maybe an equal and opposite here - maybe the Terminal should have it's CWD set to system32 when it's run elevated. That seems like pseudo-security, but there's some precedent here discussed in #7062.

    I don't think that's incompatible with #7062. I just wonder if there's perhaps a reason why it shouldn't be automatic. Is there a vector for malicious.exe to get elevated when the CWD is set to something other than system32, that it wouldn't otherwise be able to do just by inserting itself into the profile? I doubt it, but I'm no security expert.

  7. EskimoRuler commented on May 31, 2023

    @EskimoRuler
    Author

    Hmmmmmm.

    This almost looks like a dupe of #15173, but subtly different.

    With #15173, it's sufficient to just pass -d <path> to elevate-shim, to open the new tab in the requested directory.

    This however, requests that elevate-shim somehow communicates that the Terminal itself should set it's CWD. In this case, the auto-self-elevate case, we need to pass the current virtual directory of the terminal to the elevate shim, to pass to the new one. Ew. Almost like #4637

    I dunno if this regressed in 1.16 or was always broken.

    This did work in previous versions. It broke with the latest. Been tough dealing with it not working. Was just so used to the workflow being able to switch to different consoles for the same directory.

  8. medallyon commented on Jun 8, 2023

    @medallyon

    I am also experiencing this bug on Windows 11 version 10.0.22621.1702. I believe this still works on my other PC which probably uses an older version. Will verify soon.

  9. zadjii-msft commented on Jun 8, 2023

    @zadjii-msft
    Member

    FWIW I'm pretty confident this isn't a OS version issue, this is a Terminal version issue. Terminal 1.16 includes the change that regressed this, regardless of OS version

  10. MitchRazga commented on May 3, 2026

    @MitchRazga

    Kayla Cinnamon (@cinnamon-msft) James Montemagno (@jamesmontemagno) I recently watched the "Kayla Makes James' Windows Terminal Awesome" livestream and it inspired me to actually take a look at what settings are available! 😄

    The Use parent process directory setting would be a brilliant productivity boost but unfortunately this issue is blocking me from using it.
    This thread is a bit stale, but several dupes have been opened since, so it seems like it is causing friction for others too.
    Is a fix for this still being considered?

  11. Ankith-B commented on Oct 11, 2026

    @Ankith-B

    I'd like to work on this, following the walkthrough. Could I be assigned?

    From reading main: _maybeElevate passes -d for the first tab, but the elevated window's own initial CWD comes from GetCurrentDirectory() in the new elevated process, which is System32 after a runas elevation. So subsequent tabs using "Use parent process directory" resolve against System32. The unelevated version of this (#18604) was fixed in #18801, but the elevated handoff still loses the original window's CWD.

    Since an elevated process can't inherit the CWD (and as far as I can tell runas doesn't honor lpDirectory for this launch path; I'll confirm when testing), I think the original window's VirtualWorkingDirectory has to travel on the elevated command line. Two options:

    1. A hidden top-level arg (e.g. --initial-cwd <path>) that _OpenElevatedWT adds and TerminalWindow uses for SetInitialCwd.
    2. Reuse the first new-tab -d value as the window's initial CWD, but only for elevate-shim handoffs.

    I saw your note about whether an elevated Terminal should stay in System32 (#7062). If you'd rather keep that behavior, I'm happy to close this out differently.

    Which would you prefer? Happy to take a different direction.

  12. DHowett commented on Oct 12, 2026

    @DHowett
    Member

    Happy to take a different direction.

    You seem to be a robot. Follow our AI contribution guidelines or face the consequences.

  13. Ankith-B commented on Oct 12, 2026

    @Ankith-B

    22. > Happy to take a different direction.

     You seem to be a robot. Follow our AI contribution guidelines or face the consequences.
    

    I am not a robot. Would you be able to unhide my message because it says hidden as spam.

  14. DHowett commented on Oct 12, 2026

    @DHowett
    Member

    You're not? Then where did this mysterious 22 come from, and why did another random user who I also suspect of being a robot reply with a 21 only a minute earlier?

    TLDR follow our AI guidelines or do not return.

  15. MitchRazga commented on Oct 12, 2026

    @MitchRazga

    Dustin L. Howett (@DHowett) It peaked my interest that those comments had those random numbers so I looked into it and to give them the benefit of the doubt it might actually be this GitHub bug: https://github.com/orgs/community/discussions/209947

  16. DHowett commented on Oct 12, 2026

    @DHowett
    Member

    Mitch Razga (@MitchRazga) oh wow, that's actually really helpful! Thank you, and good find :)

  17. Ankith-B commented on Oct 12, 2026

    @Ankith-B

    Whenever I click "quote in reply", the number 22 just appears there.

    Also, would you be able to assign this bug to me?

  18. DHowett commented on Oct 12, 2026

    @DHowett
    Member

    Also, would you be able to assign this bug to me?

    As a rule, we do not assign bugs to people who show up out of nowhere and ask. It just adds more work for us when that person invariably disappears.

    As you can tell, this work has not been started and nobody is really talking about it except for you. You do not need to be assigned to submit a pull request, so you are welcome to step up to the plate and submit one. You do not need our permission.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Area-UserInterfaceIssues pertaining to the user interface of the Console or TerminalHelp WantedWe encourage anyone to jump in on these.Issue-BugIt either shouldn't be doing this or needs an investigation.Priority-3A description (P3)Product-TerminalThe new Windows Terminal.

    Type

    No type

    Projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions