Wrong wt.exe binary picked up when invoked through explorer's search bar #10692

Closed
opened 2026-01-31 02:27:33 +00:00 by claunia · 11 comments
Owner

Originally created by @erikha1501 on GitHub (Sep 19, 2020).

Environment

Windows build number:
Microsoft Windows [Version 10.0.19041.508]

Windows Terminal version (if applicable):
1.3.200825002-release1.3 (installed through Microsoft store)

Steps to reproduce

  1. Open Windows Explorer
  2. Type in the search box "wt" or "wt -d ." then hit enter
  3. Check the path where wt.exe is located. It looks something like this: "C:\Program Files\WindowsApps\Microsoft.WindowsTerminalPreview_1.3.2382.0_x64__8wekyb3d8bbwe\wt.exe"
    The newly opened Windows Terminal has this info:
Windows Terminal (Unpackaged)
Version: 1.3.200825002-release1.3

Expected behavior

The actual wt.exe binary should be located at "~\AppData\Local\Microsoft\WindowsApps\wt.exe". Running wt.exe through:

  • Run Dialog (Win+R)
  • Start (typing "wt" in Windows search)
  • Explorer's search bar

yield the same result.
However if I run it via cmd or powershell the correct Windows Terminal shows up.

I'm not sure if this is a bug in the terminal installation process or my windows environment is messed up. Here's a few things I noticed:

  • "~\AppData\Local\Microsoft\WindowsApps" directory is included in the PATH environment variable
  • PATH does not contain anything like "C:\Program Files\WindowsApps"
  • The "wrong" version of wt.exe fires up a Windows Terminal associated with a settings.json file located at "~\AppData\Local\Microsoft\Windows Terminal\settings.json". In contrast the normal settings.json lives at "~\AppData\Local\Packages\Microsoft.WindowsTerminalPreview_8wekyb3d8bbwe\LocalState\settings.json"
  • This problem persists if I switch to the stable version of Windows Terminal
Originally created by @erikha1501 on GitHub (Sep 19, 2020). <!-- 🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨 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! --> <!-- This bug tracker is monitored by Windows Terminal development team and other technical folks. **Important: When reporting BSODs or security issues, DO NOT attach memory dumps, logs, or traces to Github issues**. Instead, send dumps/traces to secure@microsoft.com, referencing this GitHub issue. If this is an application crash, please also provide a Feedback Hub submission link so we can find your diagnostic data on the backend. Use the category "Apps > Windows Terminal (Preview)" and choose "Share My Feedback" after submission to get the link. Please use this form and describe your issue, concisely but precisely, with as much detail as possible. --> # Environment ```none Windows build number: Microsoft Windows [Version 10.0.19041.508] Windows Terminal version (if applicable): 1.3.200825002-release1.3 (installed through Microsoft store) ``` # Steps to reproduce 1. Open Windows Explorer 2. Type in the search box "wt" or "wt -d ." then hit enter 3. Check the path where wt.exe is located. It looks something like this: "C:\Program Files\WindowsApps\Microsoft.WindowsTerminalPreview_1.3.2382.0_x64__8wekyb3d8bbwe\wt.exe" The newly opened Windows Terminal has this info: ``` Windows Terminal (Unpackaged) Version: 1.3.200825002-release1.3 ``` <!-- A description of how to trigger this bug. --> # Expected behavior The actual wt.exe binary should be located at "\~\AppData\Local\Microsoft\WindowsApps\wt.exe". Running wt.exe through: - Run Dialog (Win+R) - Start (typing "wt" in Windows search) - Explorer's search bar yield the same result. However if I run it via cmd or powershell the correct Windows Terminal shows up. I'm not sure if this is a bug in the terminal installation process or my windows environment is messed up. Here's a few things I noticed: - "\~\AppData\Local\Microsoft\WindowsApps" directory is included in the PATH environment variable - PATH does not contain anything like "C:\Program Files\WindowsApps" - The "wrong" version of wt.exe fires up a Windows Terminal associated with a settings.json file located at "\~\AppData\Local\Microsoft\Windows Terminal\settings.json". In contrast the normal settings.json lives at "\~\AppData\Local\Packages\Microsoft.WindowsTerminalPreview_8wekyb3d8bbwe\LocalState\settings.json" - This problem persists if I switch to the stable version of Windows Terminal
claunia added the Issue-QuestionNeeds-Tag-FixResolution-Answered labels 2026-01-31 02:27:33 +00:00
Author
Owner

@erikha1501 commented on GitHub (Sep 21, 2020):

It seems like the installation process adds 2 following entries to registry:

HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\wt.exe
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\wt.exe

Each has a pair of [Default] and Path string values pointing to the "wrong" wt.exe binary. Windows Explorer and Run Dialog Box might query this information to locate wt.exe. After removing these 2 entries, the expected behavior is observed.

@erikha1501 commented on GitHub (Sep 21, 2020): It seems like the installation process adds 2 following entries to registry: ``` HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\wt.exe HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\wt.exe ``` Each has a pair of [Default] and Path string values pointing to the "wrong" wt.exe binary. Windows Explorer and Run Dialog Box might query this information to locate wt.exe. After removing these 2 entries, the expected behavior is observed.
Author
Owner

@zadjii-msft commented on GitHub (Sep 21, 2020):

@DHowett @cinnamon-msft we should author a docs page about how wt works with both stable and preview installed, and how to pick which one you want to use in the settings app, since we keep getting this issue

@zadjii-msft commented on GitHub (Sep 21, 2020): @DHowett @cinnamon-msft we should author a docs page about how `wt` works with both stable and preview installed, and how to pick which one you want to use in the settings app, since we keep getting this issue
Author
Owner

@DHowett commented on GitHub (Sep 21, 2020):

@zadjii-msft so this is weird—it doesn’t look like stable vs preview here, it looks like one of their versions is unpackaged.

@erikha1501 you haven’t changed any permissions in Program Files\WindowsApps, have you?

@DHowett commented on GitHub (Sep 21, 2020): @zadjii-msft so this is weird—it doesn’t look like stable vs preview here, it looks like one of their versions is _unpackaged_. @erikha1501 you haven’t changed any permissions in Program Files\WindowsApps, have you?
Author
Owner

@erikha1501 commented on GitHub (Sep 21, 2020):

I once took ownership of Program Files\WindowsApps to give me full control access. I added an permission entry then gave the ownership back to TrustedInstaller. This might be the culprit.

@erikha1501 commented on GitHub (Sep 21, 2020): I once took ownership of Program Files\WindowsApps to give me full control access. I added an permission entry then gave the ownership back to TrustedInstaller. This might be the culprit.
Author
Owner

@DHowett commented on GitHub (Sep 21, 2020):

So, the files in that directory are usually only protected by the permissions that stop you from seeing them.

I believe that if the files in that folder are visible, the App Paths entry for wt might accidentally launch it directly out of Program Files. This would be like taking the contents of the application and running them without the rest of the package identity.

Terminal sorta supports this, but it's supposed to be by user choice.

If you remove the permission entry that you added, does the issue go away?

@DHowett commented on GitHub (Sep 21, 2020): So, the files in that directory are usually only protected by the permissions that stop you from seeing them. I believe that _if the files in that folder are visible_, the `App Paths` entry for `wt` might accidentally launch it directly out of Program Files. This would be like taking the contents of the application and running them without the rest of the package identity. Terminal sorta supports this, but it's supposed to be by user choice. If you remove the permission entry that you added, does the issue go away?
Author
Owner

@KalleOlaviNiemitalo commented on GitHub (Sep 21, 2020):

So, the files in that directory are usually only protected by the permissions that stop you from seeing them.

On Windows 10 version 2004 (OS Build 19041.508), I am able to list the files with dir "C:\Program Files\WindowsApps\Microsoft.WindowsTerminalPreview_1.3.2382.0_x64__8wekyb3d8bbwe" and run wt.exe from there, as a standard user. I have not changed the permissions nor ownership there. On the other hand, dir "C:\Program Files\WindowsApps" does not work, unless elevated.

@KalleOlaviNiemitalo commented on GitHub (Sep 21, 2020): > So, the files in that directory are usually only protected by the permissions that stop you from seeing them. On Windows 10 version 2004 (OS Build 19041.508), I am able to list the files with `dir "C:\Program Files\WindowsApps\Microsoft.WindowsTerminalPreview_1.3.2382.0_x64__8wekyb3d8bbwe"` and run `wt.exe` from there, as a standard user. I have not changed the permissions nor ownership there. On the other hand, `dir "C:\Program Files\WindowsApps"` does not work, unless elevated.
Author
Owner

@erikha1501 commented on GitHub (Sep 22, 2020):

If you remove the permission entry that you added, does the issue go away?

It did. After removing the entry and reinstalling Windows Terminal, the "unpackaged" version goes away.
I still can take a peak inside Program Files\WindowsApps\Microsoft.WindowsTerminal_1.2.2381.0_x64__8wekyb3d8bbwe, run wt.exe directly and it still works. Somehow that previously added permission entry prevented Windows Terminal from installing/running correctly. Messing with Program Files\WindowsApps folder was not a good idea after all.

@DHowett @cinnamon-msft we should author a docs page about how wt works with both stable and preview installed, and how to pick which one you want to use in the settings app, since we keep getting this issue

Documentation on how wt.exe works is definitely welcomed.

@erikha1501 commented on GitHub (Sep 22, 2020): > If you remove the permission entry that you added, does the issue go away? It did. After removing the entry and reinstalling Windows Terminal, the "unpackaged" version goes away. I still can take a peak inside `Program Files\WindowsApps\Microsoft.WindowsTerminal_1.2.2381.0_x64__8wekyb3d8bbwe`, run `wt.exe` directly and it still works. Somehow that previously added permission entry prevented Windows Terminal from installing/running correctly. Messing with `Program Files\WindowsApps` folder was _not_ a good idea after all. > @DHowett @cinnamon-msft we should author a docs page about how `wt` works with both stable and preview installed, and how to pick which one you want to use in the settings app, since we keep getting this issue Documentation on how `wt.exe` works is definitely welcomed.
Author
Owner

@DHowett commented on GitHub (Sep 22, 2020):

Thanks for confirming! I'm gonna close this as resolved, but the learnings are still pretty interesting. I can bring them back to the application install folks -- they own the code that writes the App Paths entries that have been implicated in a number of our issues.

wt.exe actually just runs WindowsTerminal.exe from the same folder. There's nothing special about it; it's just that Terminal supports running inside and outside a "package" and it was never expected that it would be able to run outside of a package even though it had been installed inside one!

@DHowett commented on GitHub (Sep 22, 2020): Thanks for confirming! I'm gonna close this as resolved, but the learnings are still pretty interesting. I can bring them back to the application install folks -- they own the code that writes the App Paths entries that have been implicated in a number of our issues. `wt.exe` actually just runs `WindowsTerminal.exe` from the same folder. There's nothing special about it; it's just that Terminal supports running inside and outside a "package" and it was never expected that it would be able to run outside of a package even though it had been installed _inside_ one!
Author
Owner

@erikha1501 commented on GitHub (Sep 22, 2020):

wt.exe actually just runs WindowsTerminal.exe from the same folder

It definitely does more than just runs WindowsTerminal.exe as I can't get WindowsTerminal.exe to run on its own (Windows cannot access the specified device, path... error pops up if I try to do so). I suppose this behavior is intended. Nevertheless I can always look at the source code to see what wt.exe does.

Anyway thanks for the support on this one!

@erikha1501 commented on GitHub (Sep 22, 2020): > `wt.exe` actually just runs `WindowsTerminal.exe` from the same folder It definitely does more than just runs `WindowsTerminal.exe` as I can't get `WindowsTerminal.exe` to run on its own (`Windows cannot access the specified device, path...` error pops up if I try to do so). I suppose this behavior is intended. Nevertheless I can always look at the source code to see what `wt.exe` does. Anyway thanks for the support on this one!
Author
Owner

@DHowett commented on GitHub (Sep 22, 2020):

I promise you that's all it does on our side. Here's the source, all 36 lines of it: https://github.com/microsoft/terminal/blob/master/src/cascadia/wt/shim.cpp

The app platform sets up permissions such that wt.exe is the only executable in the package that can be invoked directly -- this is part of the "app execution alias" infrastructure that populates %LOCALAPPDATA%\microsoft\windowsapps and in general does the work of exposing packaged executables as "normal" executables.

@DHowett commented on GitHub (Sep 22, 2020): I promise you that's all it does on our side. Here's the source, all 36 lines of it: https://github.com/microsoft/terminal/blob/master/src/cascadia/wt/shim.cpp The app platform sets up permissions such that `wt.exe` is the only executable in the package that can be invoked directly -- this is part of the "app execution alias" infrastructure that populates `%LOCALAPPDATA%\microsoft\windowsapps` and in general does the work of exposing packaged executables as "normal" executables.
Author
Owner

@DHowett commented on GitHub (Sep 22, 2020):

But all of that stuff happens outside of our codebase, in the AppXSvc system service. The extent of our code is "just launch WindowsTerminal.exe". Once the process has "package identity" granted to it by the OS, it's allowed to do so.

@DHowett commented on GitHub (Sep 22, 2020): But all of that stuff happens outside of our codebase, in the `AppXSvc` system service. The extent of our code is "just launch WindowsTerminal.exe". Once the process has "package identity" granted to it by the OS, it's allowed to do so.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#10692