admin管理员组

文章数量:1356709

The setting file of windows terminal on my PC lies in the directory "C:\Users\gaoqiang\AppData\Local\Packages\Microsoft.WindowsTerminal_8wekyb3d8bbwe\LocalState". I have a question on this path. What's the meaning of "_8wekyb3d8bbwe"? Is it safe to write this path in a script? I mean, does this path change in different version of windows terminal, or different version of windows?

The setting file of windows terminal on my PC lies in the directory "C:\Users\gaoqiang\AppData\Local\Packages\Microsoft.WindowsTerminal_8wekyb3d8bbwe\LocalState". I have a question on this path. What's the meaning of "_8wekyb3d8bbwe"? Is it safe to write this path in a script? I mean, does this path change in different version of windows terminal, or different version of windows?

Share Improve this question edited Mar 31 at 8:11 Junjie Zhu - MSFT 3,0491 gold badge4 silver badges8 bronze badges asked Mar 31 at 7:41 gaoqianggaoqiang 1011 bronze badge
Add a comment  | 

2 Answers 2

Reset to default 1

Unfortunately, this path is not reliable. In fact, most of the time Windows Terminal (WT) retrieves its configuration from
%LOCALAPPDATA%\Packages\Microsoft.WindowsTerminal_8wekyb3d8bbwe\LocalState (8wekyb3d8bbwe is Microsoft's PublisherId and ensures that names won't be conflicted if another editor also distributes an application named Windows Terminal). If that path exists, in principle it should be the right one.

However, on my work PC, WT stores its configuration in
%LOCALAPPDATA%\Microsoft\Windows Terminal: this is enforced by my company's GPOs, which notably block access to the Windows Store - so we obtain the applications that would normally be there from a different source, which does things its own way. There is also no suitable registry key to locate the WT path - not without a fairly in-depth registry analysis, which wouldn’t be much simpler or faster than searching for all the settings.json files on the PC.

You can try the default path and look for the settings.json file there. If it isn’t found, you can search for this file throughout the entire %LOCALAPPDATA% directory tree (maybe only Packages and Microsoft subfolders first?), and if that still doesn’t work, across the entire PC (excluding network and removable drives, of course).

To confirm that the file found is indeed the correct one, the presence of at least one of the following JSON keys seems sufficient:

  • "$help": "https://aka.ms/terminal-documentation"
  • "$schema": "https://aka.ms/terminal-profiles-schema-preview"

So long as you're always just using the stable version of the Windows Terminal, as downloaded from

  • the Microsoft Store
  • winget
  • the .msix straight from the Terminal releases

then

%LocalAppData%\Packages\Microsoft.WindowsTerminal_8wekyb3d8bbwe\LocalState\settings.json

will always be the path to your settings file. That's the path that the packaged installation of the Terminal uses. This is the default install that most users have.

There's a couple edge cases that don't apply to everyone:

  • As @Wisblade mentioned: Unpackaged installs. This is for folks that can't use packages for some reason or another[^1]. Those installs will use %LOCALAPPDATA%\Microsoft\Windows Terminal as the path to the settings.
  • There's also Portable installs. These are unpackaged installs with an added settings/ directory next to WindowsTerminal.exe. In that case, the settings file will live in that directory.

You can read more about the different types of Terminal installs here: Windows Terminal Distribution Types

If you're writing a tool for yourself, then you're probably fine just picking the one you use, and hardcoding that.


[^1]: FWIW, their could use the Preinstall_Kit.zip we ship to avoid needing a dependency on the Store.

本文标签: