Skip to content

PATH in child process includes Windows Terminal Preview installation directory, if started via Win+R wt.exe #7204

Closed
@KalleOlaviNiemitalo

Description

@KalleOlaviNiemitalo

Environment

Windows build number: Microsoft Windows [Version 10.0.19041.388]
Windows Terminal version (if applicable): Windows Terminal Preview 1.2.2022.0

Steps to reproduce

  1. Enable the wt.exe app execution alias of Windows Terminal Preview.
  2. Press Windows+R to open the Run dialog box.
  3. Type wt.exe and press Enter to start Windows Terminal Preview.
  4. In Windows Terminal Preview, start the Command Prompt profile.
  5. In the Command Prompt session, type PATH and press Enter.

Expected behavior

The displayed value of PATH does not include the directory where Windows Terminal Preview was installed.

Actual behavior

C:\Program Files\WindowsApps\Microsoft.WindowsTerminalPreview_1.2.2022.0_x64__8wekyb3d8bbwe is the first directory in PATH.

Notes

This is presumably caused by the Registry values that were created by AppXSvc when Windows Terminal Preview was installed:

Windows Registry Editor Version 5.00

[HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\wt.exe]
@="C:\\Program Files\\WindowsApps\\Microsoft.WindowsTerminalPreview_1.2.2022.0_x64__8wekyb3d8bbwe\\wt.exe"
"Path"="C:\\Program Files\\WindowsApps\\Microsoft.WindowsTerminalPreview_1.2.2022.0_x64__8wekyb3d8bbwe"

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\wt.exe]
@="C:\\Program Files\\WindowsApps\\Microsoft.WindowsTerminalPreview_1.2.2022.0_x64__8wekyb3d8bbwe\\wt.exe"
"Path"="C:\\Program Files\\WindowsApps\\Microsoft.WindowsTerminalPreview_1.2.2022.0_x64__8wekyb3d8bbwe"

According to Application Registration, ShellExecuteEx prepends the data of the "Path" Registry value to the PATH environment variable of the new process. That seems unnecessary here, as selecting Windows Terminal Preview from the Start menu does not add to PATH.

Because non-packaged processes of users have no access to the "C:\Program Files\WindowsApps" directory, this addition to PATH perhaps does not cause problems. However, if wt.exe is run as administrator, then the PATH addition could cause a process in the terminal session to load DLLs from the installation directory of Windows Terminal Preview. (If a packaged application is run within the terminal session, then that too would have access to the directory, but Search Order for Windows Store apps looks like the PATH environment variable will not affect DLL loading in that case.)

Related to #6860, #6748, #7188. Found while searching for possible causes of #7195.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Area-TerminalConnectionIssues pertaining to the terminal<->backend connection interfaceCulprit-CentennialIssue-BugIt either shouldn't be doing this or needs an investigation.Priority-2A description (P2)Product-TerminalThe new Windows Terminal.Resolution-Fix-CommittedFix is checked in, but it might be 3-4 weeks until a release.

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions