Allow CUI apps to provide a WT profile through the registry #11338

Open
opened 2026-01-31 02:44:53 +00:00 by claunia · 6 comments
Owner

Originally created by @PhMajerus on GitHub (Nov 11, 2020).

I know the first reaction of the Windows Terminal team will be that JSON is much better than the registry, especially for WSL users, and in most cases I agree, but hear me out on this one.

Windows Terminal automatically detects and add profiles for Microsoft-provided shells and WSL distros, populating the new-tab menu without user intervention.
But 3rd party shells that are Win32 CUI apps need to explain to their users how to add a profile in settings.json manually, as there is no way for Windows Terminal to automatically detect and create the proper profiles entries for all 3rd party apps.
Such shells are regularly installed using MSI packages, which are designed to be declarative target states and really should avoid using MSI custom actions which make them less reliable and impossible to process by some automated deployment tools. Adding a DLL to their installer that goes and tinker with "%LOCALAPPDATA%\Packages\Microsoft.WindowsTerminal_8wekyb3d8bbwe\LocalState\settings.json" file at install time isn't a solution, and wouldn't work when Windows Terminal is installed after.

I believe the cleanest solution for MSI-deployed Win32 shells would be to provide their profile for WT through the registry, in a well-known registry key such as HKLM|HKCU\Software\Microsoft\Windows Terminal\Profiles\ (HKLM or HKCU depending on whether the shell is installed per-user or globally).
Each Win32 shell could simply add a subkey with its profile GUID in that registry key, without even checking if Windows Terminal is currently installed or not.
Each subkey would contain values that match the profile properties provided in settings.json. These should be individual registry values to allow the installer to provide the targets for commandline, icon, startingDirectory,... as MSI variables depending on the installation directory selected by the user without having to, again, provide some custom action DLL that can generate JSON. It would also make it easy for IT to customize the profile of specific shells in their custom deployment solutions after extracting the declarations from an MSI package.
Whenever WT gets used, even if it has been installed after the shell, it could check that location for 3rd party profiles to be added to the add-tab menu, making the experience so much easier for users. It could also automatically remove profiles for any shell that has been uninstalled.

This isn't a suggestion to replace the JSON file with the registry, but to complement the current system to let 3rd party Win32 shells provide the same level of integration as PowerShell and CMD, and the registry seems like the best solution for those apps as it is supported as part of the MSI declarative packaging system.

Originally created by @PhMajerus on GitHub (Nov 11, 2020). I know the first reaction of the Windows Terminal team will be that JSON is much better than the registry, especially for WSL users, and in most cases I agree, but hear me out on this one. Windows Terminal automatically detects and add profiles for Microsoft-provided shells and WSL distros, populating the new-tab menu without user intervention. But 3rd party shells that are Win32 CUI apps need to explain to their users how to add a profile in settings.json manually, as there is no way for Windows Terminal to automatically detect and create the proper profiles entries for all 3rd party apps. Such shells are regularly installed using MSI packages, which are designed to be declarative target states and really should avoid using MSI custom actions which make them less reliable and impossible to process by some automated deployment tools. Adding a DLL to their installer that goes and tinker with "%LOCALAPPDATA%\Packages\Microsoft.WindowsTerminal_8wekyb3d8bbwe\LocalState\settings.json" file at install time isn't a solution, and wouldn't work when Windows Terminal is installed after. I believe the cleanest solution for MSI-deployed Win32 shells would be to provide their profile for WT through the registry, in a well-known registry key such as HKLM|HKCU\Software\Microsoft\Windows Terminal\Profiles\ (HKLM or HKCU depending on whether the shell is installed per-user or globally). Each Win32 shell could simply add a subkey with its profile GUID in that registry key, without even checking if Windows Terminal is currently installed or not. Each subkey would contain values that match the profile properties provided in settings.json. These should be individual registry values to allow the installer to provide the targets for commandline, icon, startingDirectory,... as MSI variables depending on the installation directory selected by the user without having to, again, provide some custom action DLL that can generate JSON. It would also make it easy for IT to customize the profile of specific shells in their custom deployment solutions after extracting the declarations from an MSI package. Whenever WT gets used, even if it has been installed after the shell, it could check that location for 3rd party profiles to be added to the add-tab menu, making the experience so much easier for users. It could also automatically remove profiles for any shell that has been uninstalled. This isn't a suggestion to replace the JSON file with the registry, but to complement the current system to let 3rd party Win32 shells provide the same level of integration as PowerShell and CMD, and the registry seems like the best solution for those apps as it is supported as part of the MSI declarative packaging system.
claunia added the Issue-FeatureArea-SettingsProduct-Terminal labels 2026-01-31 02:44:53 +00:00
Author
Owner

@zadjii-msft commented on GitHub (Nov 11, 2020):

Oh man, this is so close to what we actually already designed 😄 s/registry/well-known folder for .json files/g, and you'll get #7584.

Basically, we're going to let 3rd party applications drop a json fragment into a well-known folder path, and we'll also parse those fragments of settings as well. This'll let something like Git bash set up their own profiles, or let Canonical customize the dynamically-generated one we make on their behalf.

@zadjii-msft commented on GitHub (Nov 11, 2020): Oh man, this is so close to what we actually already designed 😄 `s/registry/well-known folder for .json files/g`, and you'll get #7584. Basically, we're going to let 3rd party applications drop a json `fragment` into a well-known folder path, and we'll also parse those fragments of settings as well. This'll let something like Git bash set up their own profiles, or let Canonical customize the dynamically-generated one we make on their behalf.
Author
Owner

@PhMajerus commented on GitHub (Nov 11, 2020):

@zadjii-msft The problem with a well-known folder for JSON files is that MSI can let the user or IT scripts change the target installation folder, and while writing a command line containing that variable to the registry is supported by MSI, generating or modifying a JSON file on the fly during the installation isn't as easy.
This means the MSI must then contain a custom actions DLL, which must be tested and debugged, compiled for each target architecture, and hated by IT as it can be simply unsupported by some tools that use MSI packages to generate purely declarative installation (desired state configuration), or simply be a security risk as it is very hard to inspect or sandbox (think App-V and others).
Remember we even moved away from MSI calling COM components DLLs self-registration functions and move to declarative COM registration instead for the exact same reasons, avoiding calling app's code during MSI installation, and COM DLLs didn't even need a custom action DLL because MSI could handle self-reg DLLs.

I know this means extra work on your side, but enabling an easy and reliable way for Win32 shells to make themselves available in Windows Terminal seems like a worthy scenario. And I promise my shell will take advantage of it as soon as it's in WT Preview. 😊

@PhMajerus commented on GitHub (Nov 11, 2020): @zadjii-msft The problem with a well-known folder for JSON files is that MSI can let the user or IT scripts change the target installation folder, and while writing a command line containing that variable to the registry is supported by MSI, generating or modifying a JSON file on the fly during the installation isn't as easy. This means the MSI must then contain a custom actions DLL, which must be tested and debugged, compiled for each target architecture, and hated by IT as it can be simply unsupported by some tools that use MSI packages to generate purely declarative installation (desired state configuration), or simply be a security risk as it is very hard to inspect or sandbox (think App-V and others). Remember we even moved away from MSI calling COM components DLLs self-registration functions and move to declarative COM registration instead for the exact same reasons, avoiding calling app's code during MSI installation, and COM DLLs didn't even need a custom action DLL because MSI could handle self-reg DLLs. I know this means extra work on your side, but enabling an easy and reliable way for Win32 shells to make themselves available in Windows Terminal seems like a worthy scenario. And I promise my shell will take advantage of it as soon as it's in WT Preview. 😊
Author
Owner

@DHowett commented on GitHub (Nov 17, 2020):

So, you're totally right. It's a bit of a miss that we didn't think about specifically how an MSI would emit this JSON blob with a customizable install location. Sorry about that.

I'm a little bit averse to adding another serialization format, however. It seems outside of Terminal's existing competency in settings parsing, and it brings in a little more of the legacy win32 stuff than I was really hoping it would.

Is emitting an environment variable and using that in a json fragment an acceptable stopgap until we figure out the right plan here?

@DHowett commented on GitHub (Nov 17, 2020): So, you're totally right. It's a bit of a miss that we didn't think about _specifically_ how an MSI would emit this JSON blob with a customizable install location. Sorry about that. I'm a little bit averse to adding _another_ serialization format, however. It seems outside of Terminal's existing competency in settings parsing, and it brings in a little more of the legacy win32 stuff than I was really hoping it would. Is emitting an environment variable and using that _in_ a json fragment an acceptable stopgap until we figure out the right plan here?
Author
Owner

@ghost commented on GitHub (Nov 21, 2020):

This issue has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 4 days. It will be closed if no further activity occurs within 3 days of this comment.

@ghost commented on GitHub (Nov 21, 2020): This issue has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for **4 days**. It will be closed if no further activity occurs **within 3 days of this comment**.
Author
Owner

@PhMajerus commented on GitHub (Nov 24, 2020):

Thanks @DHowett
I have no urgent need for it, so no need to find a temporary workaround, I just think it's an important scenario that should be supported with a proper solution at some point.

I still believe the registry is the right way to go, if the Windows Terminal is to become a frontend for all kind of CUI apps from different environments, it has to meet and accommodate these apps in their own environments.

I'll wait until you have a clean solution for Win32 CUI apps and just add a JSON profile manually in the meantime.

@PhMajerus commented on GitHub (Nov 24, 2020): Thanks @DHowett I have no urgent need for it, so no need to find a temporary workaround, I just think it's an important scenario that should be supported with a proper solution at some point. I still believe the registry is the right way to go, if the Windows Terminal is to become a frontend for all kind of CUI apps from different environments, it has to meet and accommodate these apps in their own environments. I'll wait until you have a clean solution for Win32 CUI apps and just add a JSON profile manually in the meantime.
Author
Owner

@driver1998 commented on GitHub (Dec 14, 2020):

Well you can always omit such json file to say %AppData%\Microsoft\WindowsTeminal, while still installing your CUI app to a custom location, that is not that different from using the registry.
Or somehow MSI can't write its installation location to a text file?

@driver1998 commented on GitHub (Dec 14, 2020): Well you can always omit such json file to say `%AppData%\Microsoft\WindowsTeminal`, while still installing your CUI app to a custom location, that is not that different from using the registry. Or somehow MSI can't write its installation location to a text file?
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#11338