Description
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
- Enable the
wt.exe
app execution alias of Windows Terminal Preview. - Press Windows+R to open the Run dialog box.
- Type
wt.exe
and press Enter to start Windows Terminal Preview. - In Windows Terminal Preview, start the Command Prompt profile.
- 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.