Set environment variable WT_FOLDER_PATH to the folder path that contains WindowsTerminal.exe #20794

Closed
opened 2026-01-31 07:24:16 +00:00 by claunia · 7 comments
Owner

Originally created by @daxgames on GitHub (Nov 12, 2023).

Originally assigned to: @zadjii-msft on GitHub.

Description of the new feature/enhancement

Set an environment variable WT_FOLDER_PATH to the folder path that contains WindowsTerminal.exe. This variable should be set when Windows Terminal launches before the profile is launched.

This would be useful for users that run Windows Terminal in portable mode so Windows terminal profiles can be configured with paths relative to the folder wher WIndows Terminal is installed as shown below:

image

The normal user profile is configured as shown below and works perfectly because the %CMDER_ROOT% env variable was set dynamically before launching Windows Terminal.

image

The above configuration does not work when launching as Administrator because the %CMDER_ROOT% env variable is not set globally on the system nor in the Administator's personal environment variables. it produces the error below:

image

For completeness sake the icon config being complained about in the error above is below:

image

Proposed technical implementation details (optional)

Originally created by @daxgames on GitHub (Nov 12, 2023). Originally assigned to: @zadjii-msft on GitHub. <!-- 🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨 I ACKNOWLEDGE THE FOLLOWING BEFORE PROCEEDING: 1. If I delete this entire template and go my own path, the core team may close my issue without further explanation or engagement. 2. If I list multiple bugs/concerns in this one issue, the core team may close my issue without further explanation or engagement. 3. If I write an issue that has many duplicates, the core team may close my issue without further explanation or engagement (and without necessarily spending time to find the exact duplicate ID number). 4. If I leave the title incomplete when filing the issue, the core team may close my issue without further explanation or engagement. 5. If I file something completely blank in the body, the core team may close my issue without further explanation or engagement. All good? Then proceed! --> # Description of the new feature/enhancement <!-- A clear and concise description of what the problem is that the new feature would solve. Describe why and how a user would use this new functionality (if applicable). --> Set an environment variable `WT_FOLDER_PATH` to the folder path that contains `WindowsTerminal.exe`. This variable should be set when Windows Terminal launches before the profile is launched. This would be useful for users that run Windows Terminal in portable mode so Windows terminal profiles can be configured with paths relative to the folder wher WIndows Terminal is installed as shown below: ![image](https://github.com/microsoft/terminal/assets/7318053/f77f8e2c-7c8e-48d1-a4ce-81038c653468) The normal user profile is configured as shown below and works perfectly because the `%CMDER_ROOT%` env variable was set dynamically before launching Windows Terminal. ![image](https://github.com/microsoft/terminal/assets/7318053/1bc3f646-e05d-4e69-8add-b8422a8cea90) The above configuration does not work when launching as Administrator because the `%CMDER_ROOT%` env variable is not set globally on the system nor in the Administator's personal environment variables. it produces the error below: ![image](https://github.com/microsoft/terminal/assets/7318053/ffd23d64-329c-4ae1-8e66-ebe36b563d4f) For completeness sake the icon config being complained about in the error above is below: ![image](https://github.com/microsoft/terminal/assets/7318053/7b878169-edfc-4046-9ea6-453c91703b4a) # Proposed technical implementation details (optional) <!-- A clear and concise description of what you want to happen. -->
Author
Owner

@zadjii-msft commented on GitHub (Nov 13, 2023):

This really falls under the same problem space as #13006 et al. We could add that, sure,

Wait, no it doesn't. This is actually so simple. Set that variable for terminal itself. So that we can resolve things relative to ourself. brilliant.

I think we were already tracking this in #15379 but I'll motion to use this as the tracking thread instead, since this has a real good idea. Thanks!

@zadjii-msft commented on GitHub (Nov 13, 2023): ~This really falls under the same problem space as #13006 et al. We could add that, sure,~ Wait, no it doesn't. This is actually so simple. Set that variable _for terminal itself_. So that we can resolve things relative to ourself. brilliant. I think we were already tracking this in #15379 but I'll motion to use this as the tracking thread instead, since this has a real good idea. Thanks!
Author
Owner

@daxgames commented on GitHub (May 28, 2024):

The implemented solution in https://github.com/microsoft/terminal/pull/16949:

  1. Is confusing.
  • Is it %WT_SETTINGS_DIR% or %WT_SETTINGS_PATH%
  • I THINK it is %WT_SETTINGS_DIR% because it seems to MOSTLY work.
  • Does not COMPLETELY solve this issue. See below.

New Config:

image

Launching the profile:

image

The paths exist because the shell is configured using "%WT_SETTINGS_DIR%\..\..\init.bat" and the tab icon is correctly read from "%WT_SETTINGS_DIR%......\icons\cmder_red.ico".

@daxgames commented on GitHub (May 28, 2024): The implemented solution in https://github.com/microsoft/terminal/pull/16949: 1. Is confusing. - Is it `%WT_SETTINGS_DIR%` or `%WT_SETTINGS_PATH%` - I THINK it is `%WT_SETTINGS_DIR%` because it seems to MOSTLY work. - Does not COMPLETELY solve this issue. See below. New Config: ![image](https://github.com/microsoft/terminal/assets/7318053/babb8c42-ecfd-41aa-ac1d-3399ed792e65) Launching the profile: ![image](https://github.com/microsoft/terminal/assets/7318053/d7cdf647-5dcb-4373-9f47-820123d9f38d) The paths exist because the shell is configured using `"%WT_SETTINGS_DIR%\..\..\init.bat"` and the tab icon is correctly read from "%WT_SETTINGS_DIR%\..\..\..\icons\cmder_red.ico".
Author
Owner

@daxgames commented on GitHub (May 28, 2024):

Also why can't this just be a normal env variable like the below that are set in 1.20.x:

image

Like this:

image

@daxgames commented on GitHub (May 28, 2024): Also why can't this just be a normal env variable like the below that are set in 1.20.x: ![image](https://github.com/microsoft/terminal/assets/7318053/b0919fc3-35ef-46df-bdd3-ef2058ba9854) Like this: ![image](https://github.com/microsoft/terminal/assets/7318053/d1fd464c-7f2d-4dc0-89c3-679b89d01aef)
Author
Owner

@DHowett commented on GitHub (May 28, 2024):

Image

It's WT_SETTINGS_DIR 😄
(It may not work in the commandline field - we need to investigate that. It should work in any other field in the settings that supports paths.)

@DHowett commented on GitHub (May 28, 2024): ![Image](https://github.com/microsoft/terminal/assets/189190/b95a9df2-e551-47c9-b778-5c1f2ab6e7e5) It's `WT_SETTINGS_DIR` 😄 (It may not work in the commandline field - we need to investigate that. It should work in any other field in the settings that supports paths.)
Author
Owner

@daxgames commented on GitHub (May 28, 2024):

See my edited comment above.

@daxgames commented on GitHub (May 28, 2024): See my edited comment above.
Author
Owner

@DHowett commented on GitHub (May 28, 2024):

Thanks!

@DHowett commented on GitHub (May 28, 2024): Thanks!
Author
Owner

@daxgames commented on GitHub (May 28, 2024):

Thanks for the quick response and the fix!

I looked at the PR and it went back and forth on %WT_SETTINGS_DIR% and %WT_SETTINGS_PATH%. After posting the issue I went to the Release Notes and saw the correct env var but it still throws the icon message. Other than that it all works!

My only other concern is wrapping the icon path with double quotes causes it to fail. Not sure if that would be an issue if the icon were in a path that contained spaces.

@daxgames commented on GitHub (May 28, 2024): Thanks for the quick response and the fix! I looked at the PR and it went back and forth on `%WT_SETTINGS_DIR%` and `%WT_SETTINGS_PATH%`. After posting the issue I went to the Release Notes and saw the correct env var but it still throws the icon message. Other than that it all works! My only other concern is wrapping the icon path with double quotes causes it to fail. Not sure if that would be an issue if the icon were in a path that contained spaces.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#20794