Path variable from the environment is not respected #22376

Closed
opened 2026-01-31 08:11:20 +00:00 by claunia · 11 comments
Owner

Originally created by @0xEDApps on GitHub (Oct 10, 2024).

Windows Terminal version

1.22.240926002-preview

Windows build number

10.0.22621.819

Other Software

No response

Steps to reproduce

run:
cmd.exe
type:
set path=c:\tweet;%path%
type your path to terminal:
"C:\Users\Admino\AppData\Local\Temp\WindowsTerminal\x64\WindowsTerminal.exe"
open a cmd window in terminal and type:
path

WindowsTerminal.exe shows the right path "c:\tweet;...."
OpenConsole.exe also shows the right path "c:\tweet;...."
but then cmd.exe has a different path

Expected Behavior

to see the active environment
to see "c:\tweet"

Actual Behavior

shows the wrong path
probably the environment is retrieved from the registry instead of the environment

Originally created by @0xEDApps on GitHub (Oct 10, 2024). ### Windows Terminal version 1.22.240926002-preview ### Windows build number 10.0.22621.819 ### Other Software _No response_ ### Steps to reproduce run: cmd.exe type: set path=c:\tweet;%path% type your path to terminal: "C:\Users\Admino\AppData\Local\Temp\WindowsTerminal\x64\WindowsTerminal.exe" open a cmd window in terminal and type: path WindowsTerminal.exe shows the right path "c:\tweet;...." OpenConsole.exe also shows the right path "c:\tweet;...." but then cmd.exe has a different path ### Expected Behavior to see the active environment to see "c:\tweet" ### Actual Behavior shows the wrong path probably the environment is retrieved from the registry instead of the environment
claunia added the Issue-BugResolution-Duplicate labels 2026-01-31 08:11:20 +00:00
Author
Owner

@0xEDApps commented on GitHub (Oct 10, 2024):

Checked with ProcessHacker to see the environment of individual executables

WindowsTerminal.exe shows the right path "c:\tweet;...."
OpenConsole.exe also shows the right path "c:\tweet;...."
cmd.exe has a different path

@0xEDApps commented on GitHub (Oct 10, 2024): Checked with ProcessHacker to see the environment of individual executables WindowsTerminal.exe shows the right path "c:\tweet;...." OpenConsole.exe also shows the right path "c:\tweet;...." cmd.exe has a different path
Author
Owner

@lhecker commented on GitHub (Oct 10, 2024):

Windows Terminal treats each tab and pane like a "container" of sorts. Each one gets its own fresh environment variables. You can disable that behavior here:

Image

@lhecker commented on GitHub (Oct 10, 2024): Windows Terminal treats each tab and pane like a "container" of sorts. Each one gets its own fresh environment variables. You can disable that behavior here: ![Image](https://github.com/user-attachments/assets/d192fdce-9f59-4654-8894-a4130a11e0c7)
Author
Owner

@0xEDApps commented on GitHub (Oct 10, 2024):

i see, indeed that works for new tabs but not for the one that is there when launched.

i also use these settings
default profile: Command Prompt
when terminal starts: open tab with default profile

@0xEDApps commented on GitHub (Oct 10, 2024): i see, indeed that works for new tabs but not for the one that is there when launched. i also use these settings default profile: Command Prompt when terminal starts: open tab with default profile
Author
Owner

@0xEDApps commented on GitHub (Oct 10, 2024):

Also it does not show the correct path wen a tab is created with a new instance.

i have this setting
new instance behavior: attach to the most recently used window

@0xEDApps commented on GitHub (Oct 10, 2024): Also it does not show the correct path wen a tab is created with a new instance. i have this setting new instance behavior: attach to the most recently used window
Author
Owner

@carlos-zamora commented on GitHub (Oct 16, 2024):

Thanks for filing! Assuming Windows Terminal is set as your default terminal, start cmd should create a new window and immediately hand off to windows terminal, which would then have the expected environment block. This can be used as a workaround for your scenario. If you do wt new-tab -w0 cmd, that should work too. Does that work for you ?

Note #16226 may be involved here.

@carlos-zamora commented on GitHub (Oct 16, 2024): Thanks for filing! Assuming Windows Terminal is set as your default terminal, `start cmd` should create a new window and immediately hand off to windows terminal, which would then have the expected environment block. This can be used as a workaround for your scenario. If you do `wt new-tab -w0 cmd`, that should work too. Does that work for you \? Note #16226 may be involved here.
Author
Owner

@0xEDApps commented on GitHub (Oct 17, 2024):

Thanks for filing! Assuming Windows Terminal is set as your default terminal

Don't even know how to do that, it most likely can't be automated as MS implemented encryption for default file associations, so no it is not the default

Does that work for you ?

it does, but not my preferred solution

Note #16226 may be involved here.

Good find buddy
Indeed, seems to be a reoccurring issue, you can not expect all users to start hunting for command line parameters, when the default behaviour is that a app inherits the environment from the caller.
I used --inheritEnvironment from there as the cleaner outcome

To bad MS does not respect the environment and reads the registry instead, now many other devellopers also do that, a example WindowsTerminal writes to %LocalAppdata% but uses the one from the registry, i am not gonna mess with that, i attempted it years ago, but that is a global change and all other crappie apps will start to write at the new location too, so sad :(
Maybe that should be a different issue.

@0xEDApps commented on GitHub (Oct 17, 2024): > Thanks for filing! Assuming Windows Terminal is set as your default terminal Don't even know how to do that, it most likely can't be automated as MS implemented encryption for default file associations, so no it is not the default > Does that work for you ? it does, but not my preferred solution > Note [#16226](https://github.com/microsoft/terminal/issues/16226) may be involved here. Good find buddy Indeed, seems to be a reoccurring issue, you can not expect all users to start hunting for command line parameters, when the default behaviour is that a app inherits the environment from the caller. I used `--inheritEnvironment` from there as the cleaner outcome To bad MS does not respect the environment and reads the registry instead, now many other devellopers also do that, a example WindowsTerminal writes to %LocalAppdata% but uses the one from the registry, i am not gonna mess with that, i attempted it years ago, but that is a global change and all other crappie apps will start to write at the new location too, so sad :( Maybe that should be a different issue.
Author
Owner

@DHowett commented on GitHub (Oct 17, 2024):

i am not gonna mess with that, i attempted it years ago, but that is a global change and all other crappie apps will start to write at the new location too, so sad :(
Maybe that should be a different issue.

You must know that redirecting the known folders like AppData/LocalAppData is not supported. Please don't file bugs on us, or anyone else, for that.

@DHowett commented on GitHub (Oct 17, 2024): > i am not gonna mess with that, i attempted it years ago, but that is a global change and all other crappie apps will start to write at the new location too, so sad :( Maybe that should be a different issue. You must know that redirecting the known folders like AppData/LocalAppData is not supported. Please don't file bugs on us, or anyone else, for that.
Author
Owner

@DHowett commented on GitHub (Oct 17, 2024):

Thanks for filing! Assuming Windows Terminal is set as your default terminal

Don't even know how to do that, it most likely can't be automated as MS implemented encryption for default file associations, so no it is not the default

Windows Terminal is the default console host on your version of Windows unless you've turned it off explicitly, and it does not work by using "file associations".

@DHowett commented on GitHub (Oct 17, 2024): > > Thanks for filing! Assuming Windows Terminal is set as your default terminal > > Don't even know how to do that, it most likely can't be automated as MS implemented encryption for default file associations, so no it is not the default Windows Terminal _is_ the default console host on your version of Windows unless you've turned it off explicitly, and it does not work by using "file associations".
Author
Owner

@0xEDApps commented on GitHub (Oct 17, 2024):

Windows Terminal is the default console host on your version of Windows unless you've turned it off explicitly, and it does not work by using "file associations".

Doubt that, i am on win 11 and never have i seen "windows terminal" it always shows cmd.exe or consolehost.exe

@0xEDApps commented on GitHub (Oct 17, 2024): > Windows Terminal _is_ the default console host on your version of Windows unless you've turned it off explicitly, and it does not work by using "file associations". Doubt that, i am on win 11 and never have i seen "windows terminal" it always shows cmd.exe or consolehost.exe
Author
Owner

@DHowett commented on GitHub (Oct 23, 2024):

At its heart, this is a /duplicate of #15496.

You can use the --inheritEnvironment argument or the profile setting compatibility.reloadEnvironmentVariables (set to false).

@DHowett commented on GitHub (Oct 23, 2024): At its heart, this is a /duplicate of #15496. You can use the `--inheritEnvironment` argument or the profile setting `compatibility.reloadEnvironmentVariables` (set to `false`).
Author
Owner

@microsoft-github-policy-service[bot] commented on GitHub (Oct 23, 2024):

Hi! We've identified this issue as a duplicate of another one that already exists on this Issue Tracker. This specific instance is being closed in favor of tracking the concern over on the referenced thread. Thanks for your report!

@microsoft-github-policy-service[bot] commented on GitHub (Oct 23, 2024): Hi! We've identified this issue as a duplicate of another one that already exists on this Issue Tracker. This specific instance is being closed in favor of tracking the concern over on the referenced thread. Thanks for your report! <!-- Policy app identification https://img.shields.io/static/v1?label=PullRequestIssueManagement. -->
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#22376