Strange starting directory when launched from explorer.exe's address bar #16947

Open
opened 2026-01-31 05:28:10 +00:00 by claunia · 0 comments
Owner

Originally created by @SainoNamkho on GitHub (Mar 8, 2022).

Windows Terminal version

1.4.201119003-release1.4

Windows build number

10.0.19042.685

Other Software

No response

Steps to reproduce

Config the starting directory of the default profile

{
            "guid": "{0caa0dad-35be-5f56-a8ff-afceeeaa6101}",
            "commandline": "cmd.exe",
            "startingDirectory": "%__CD__%",

Run wt from the win+r diaglog:
image
Run wt from explorer.exe's address bar when cwd of explorer is something like %userprofile%\Downloads:
image
check the %__cd__% variable:

C:\Program Files\WindowsApps\Microsoft.WindowsTerminal_1.4.3243.0_x64__8wekyb3d8bbwe>echo %cd%
C:\Program Files\WindowsApps\Microsoft.WindowsTerminal_1.4.3243.0_x64__8wekyb3d8bbwe

C:\Program Files\WindowsApps\Microsoft.WindowsTerminal_1.4.3243.0_x64__8wekyb3d8bbwe>echo %cd%\
C:\Program Files\WindowsApps\Microsoft.WindowsTerminal_1.4.3243.0_x64__8wekyb3d8bbwe\

C:\Program Files\WindowsApps\Microsoft.WindowsTerminal_1.4.3243.0_x64__8wekyb3d8bbwe>echo %__cd__%
C:\Program Files\WindowsApps\Microsoft.WindowsTerminal_1.4.3243.0_x64__8wekyb3d8bbwe\

Config the starting directory of the default profile

{
            "guid": "{0caa0dad-35be-5f56-a8ff-afceeeaa6101}",
            "commandline": "cmd.exe",
            "startingDirectory": "%CD%",

Run wt from the win+r diaglog:
image
Run wt from explorer.exe's address bar, still not same as cwd:
image

Config startingDirectory to %CD%\ or remove it from the profile:

the same as "%CD%".

Maybe related #7204 #12602

Expected Behavior

In some previous version which I cannot figure out, the terminal is launched the same path as the explorer.

Actual Behavior

I've not updated to the latest build because of a problem related to #6591, the .msixbundle file itself will cause a file system error,
but I can reproduce the problem on some other computers with new builds.


Additional problem:
The wt launched by explorer differs from that launched by win+r dialog not only in starting directory. There's also a special environment variable when launched from explorer.
Run !peb in WinDbg will get
image
This is the one launched from win+r
image
And the entry =::=::\ is added to explorer's environment after the terminal process is spawned.

Originally created by @SainoNamkho on GitHub (Mar 8, 2022). ### Windows Terminal version 1.4.201119003-release1.4 ### Windows build number 10.0.19042.685 ### Other Software _No response_ ### Steps to reproduce #### Config the starting directory of the default profile ```json { "guid": "{0caa0dad-35be-5f56-a8ff-afceeeaa6101}", "commandline": "cmd.exe", "startingDirectory": "%__CD__%", ``` Run `wt` from the <kbd>win</kbd>+<kbd>r</kbd> diaglog: ![image](https://user-images.githubusercontent.com/23036788/157195917-98c3fe8e-d96b-45c9-87b0-831c21d995e6.png) Run `wt` from explorer.exe's address bar when cwd of explorer is something like `%userprofile%\Downloads`: ![image](https://user-images.githubusercontent.com/23036788/157196030-707b5f91-ba2e-406d-bbe0-29db1bd2687d.png) check the `%__cd__%` variable: ```cmd C:\Program Files\WindowsApps\Microsoft.WindowsTerminal_1.4.3243.0_x64__8wekyb3d8bbwe>echo %cd% C:\Program Files\WindowsApps\Microsoft.WindowsTerminal_1.4.3243.0_x64__8wekyb3d8bbwe C:\Program Files\WindowsApps\Microsoft.WindowsTerminal_1.4.3243.0_x64__8wekyb3d8bbwe>echo %cd%\ C:\Program Files\WindowsApps\Microsoft.WindowsTerminal_1.4.3243.0_x64__8wekyb3d8bbwe\ C:\Program Files\WindowsApps\Microsoft.WindowsTerminal_1.4.3243.0_x64__8wekyb3d8bbwe>echo %__cd__% C:\Program Files\WindowsApps\Microsoft.WindowsTerminal_1.4.3243.0_x64__8wekyb3d8bbwe\ ``` #### Config the starting directory of the default profile ```json { "guid": "{0caa0dad-35be-5f56-a8ff-afceeeaa6101}", "commandline": "cmd.exe", "startingDirectory": "%CD%", ``` Run `wt` from the <kbd>win</kbd>+<kbd>r</kbd> diaglog: ![image](https://user-images.githubusercontent.com/23036788/157196133-58168f24-c4a7-498e-8672-1fa2c5ba003d.png) Run `wt` from explorer.exe's address bar, still not same as cwd: ![image](https://user-images.githubusercontent.com/23036788/157196133-58168f24-c4a7-498e-8672-1fa2c5ba003d.png) #### Config `startingDirectory` to `%CD%\` or remove it from the profile: the same as `"%CD%"`. Maybe related #7204 #12602 ### Expected Behavior In some previous version which I cannot figure out, the terminal is launched the same path as the explorer. ### Actual Behavior I've not updated to the latest build because of a problem related to #6591, the `.msixbundle` file itself will cause a file system error, but I can reproduce the problem on some other computers with new builds. --- Additional problem: The `wt` launched by explorer differs from that launched by `win+r` dialog not only in starting directory. There's also a special environment variable when launched from explorer. Run `!peb` in WinDbg will get ![image](https://user-images.githubusercontent.com/23036788/157199308-d10e558e-4c56-4a87-9057-9ca064c4b5f6.png) This is the one launched from `win+r` ![image](https://user-images.githubusercontent.com/23036788/157200047-94ed3137-099b-4477-868c-966c319ed535.png) And the entry `=::=::\` is added to explorer's environment after the terminal process is spawned.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#16947