-
Notifications
You must be signed in to change notification settings - Fork 8.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
PATH in child process includes Windows Terminal Preview installation directory, if started via Win+R wt.exe #7204
Comments
So, a few notes.
|
Incidentally, this and the last seven issues are the first (and second through seventh) times I've ever heard of |
How do you elevate it? If I type |
Yep, using Ctrl+Shift+Enter from the Run dialog. |
I imagine Windows Terminal could explicitly delete its installation directory from PATH in the environment block that it passes to CreateProcess. Or use CreateEnvironmentBlock as suggested in #1125, instead of copying PATH and other variables from the environment of the WindowsTerminal.exe process.
That's strange… Are you using the same version of Windows 10? Does the PATH change even get to the WindowsTerminal.exe process? Process Monitor filtering with Operation = Process Start is handy for checking this. |
This commit ensures that we always furnish a new process with the cleanest, most up-to-date environment variables we can. There is a minor cost here in that WT will no longer pass environment variables that it itself inherited to its child processes. This could be considered a reasonable sacrifice. It will also remove somebody else's TERM, TERM_PROGRAM and TERM_PROGRAM_VERSION from the environment, which could be considered a win. Related to #1125 (but it does not close it or resolve any of the other issues it calls out.) Fixes #7239 Fixes #7204 ("App Paths" value creeping into wt's environment)
This commit ensures that we always furnish a new process with the cleanest, most up-to-date environment variables we can. There is a minor cost here in that WT will no longer pass environment variables that it itself inherited to its child processes. This could be considered a reasonable sacrifice. It will also remove somebody else's TERM, TERM_PROGRAM and TERM_PROGRAM_VERSION from the environment, which could be considered a win. I validated that GetCurrentProcessToken returns a token we're _technically able_ to use with this API; it is roughly equivalent to OpenProcessToken(GetCurrentProcess) in that it returns the current active _access token_ (which is what CreateEnvironmentBlock wants.) There's been discussion about doing a 3-way merge between WT's environment and the new one. This will be complicated and I'd like to scream test the 0-way merge first ;P Related to #1125 (but it does not close it or resolve any of the other issues it calls out.) Fixes #7239 Fixes #7204 ("App Paths" value creeping into wt's environment)
🎉This issue was addressed in #7243, which has now been successfully released as Handy links: |
#7243 did not fix this for the following child processes:
According to #7460, the extra entry in Please reopen. |
Huh. |
@DHowett not sure if this is related but when I do EDIT: It was this problem. I deleted the above registry keys and restarted, put the wt preview in my path, and everything works fine. |
Retested with Windows Terminal Preview 1.12.3472.0 on Windows 10.0.19044.1415:
|
Merging notes:
Probably also related:
So, we added dupes?
internal work
Conclusions:
[1]: See #6860 which was supposed to fix #6625:
|
A thought: This might have been fixed by #14999. |
Yep - looks like it: And if I set |
Environment
Steps to reproduce
wt.exe
app execution alias of Windows Terminal Preview.wt.exe
and press Enter to start Windows Terminal Preview.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:
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.
The text was updated successfully, but these errors were encountered: