Add protocol handler to open new tab in existing Windows Terminal #12440

Closed
opened 2026-01-31 03:15:40 +00:00 by claunia · 8 comments
Owner

Originally created by @awakecoding on GitHub (Feb 6, 2021).

Description of the new feature/enhancement

Add a protocol handler (winterm://) to allow opening a new tab inside the existing Windows Terminal, instead of opening a new Windows Terminal. The current "Open in Windows Terminal" contextual menu option unfortunately always open a new Windows Terminal, instead of adding a new tab to the current one. The goal is to make it easier for third-party programs to implement richer "Open in Windows Terminal" functionality, where a new tab with a special profile is opened with an initial command injected. In our case, we intend to launch PowerShell remoting sessions from Remote Desktop Manager inside Windows Terminal. We currently supported embedded tabs inside Remote Desktop Manager, or we can launch the old boring blue PowerShell terminal externally. Since the old PowerShell terminal doesn't support tabs anyway, it has never been an issue.

Proposed technical implementation details

Regardless of the final name for the protocol handler (I suggest winterm://) the implementation is relatively simple: on startup, you check for the presence of an existing Windows Terminal instance. If there is one, you send the URL string passed through the protocol handler to the other process, and terminate. The receiving instance receives the URL and processes it to open a new tab with the specified profile id. We have implemented something like this to open new connections in our remote desktop program.

the URL string should contain at a bare minimum a profile id, and accept additional parameters following the same format found in settings.json:

winterm://34a13805-9b56-5e89-9234-f02de44bd971?name=Name?command=Command

Since addition parameters like the name and the command will likely contain characters causing trouble, I suggest that we either URL-encode them, or define them to always be encoded as UTF-8 base64url strings, whichever feels best.

The ideal solution would be to support temporary profiles, such that if the profile id doesn't exist, it could be created on-the-fly with all the parameters passed. This would be very useful as external programs could inject meaningful names, and even give a path to an icon file to use. In our case, system administrators can manage thousands of entries in Remote Desktop Manager, so everything that makes it easier to give identifying or distinctive information is a big win.

If we can have such a mechanism in place, we have everything we need for a possible integration, and nothing prevents other vendors from offering similar integration with relatively little effort. The good news is that it would also be relatively decoupled from Windows Terminal.

Originally created by @awakecoding on GitHub (Feb 6, 2021). # Description of the new feature/enhancement Add a protocol handler (winterm://) to allow opening a new tab inside the existing Windows Terminal, instead of opening a new Windows Terminal. The current "Open in Windows Terminal" contextual menu option unfortunately always open a new Windows Terminal, instead of adding a new tab to the current one. The goal is to make it easier for third-party programs to implement richer "Open in Windows Terminal" functionality, where a new tab with a special profile is opened with an initial command injected. In our case, we intend to launch PowerShell remoting sessions from Remote Desktop Manager inside Windows Terminal. We currently supported embedded tabs inside Remote Desktop Manager, or we can launch the old boring blue PowerShell terminal externally. Since the old PowerShell terminal doesn't support tabs anyway, it has never been an issue. # Proposed technical implementation details Regardless of the final name for the protocol handler (I suggest winterm://) the implementation is relatively simple: on startup, you check for the presence of an existing Windows Terminal instance. If there is one, you send the URL string passed through the protocol handler to the other process, and terminate. The receiving instance receives the URL and processes it to open a new tab with the specified profile id. We have implemented something like this to open new connections in our remote desktop program. the URL string should contain at a bare minimum a profile id, and accept additional parameters following the same format found in settings.json: winterm://34a13805-9b56-5e89-9234-f02de44bd971?name=Name?command=Command Since addition parameters like the name and the command will likely contain characters causing trouble, I suggest that we either URL-encode them, or define them to always be encoded as UTF-8 base64url strings, whichever feels best. The ideal solution would be to support temporary profiles, such that if the profile id doesn't exist, it could be created on-the-fly with all the parameters passed. This would be very useful as external programs could inject meaningful names, and even give a path to an icon file to use. In our case, system administrators can manage thousands of entries in Remote Desktop Manager, so everything that makes it easier to give identifying or distinctive information is a big win. If we can have such a mechanism in place, we have everything we need for a possible integration, and nothing prevents other vendors from offering similar integration with relatively little effort. The good news is that it would also be relatively decoupled from Windows Terminal.
claunia added the Issue-FeatureResolution-Duplicate labels 2026-01-31 03:15:40 +00:00
Author
Owner

@j4james commented on GitHub (Feb 6, 2021):

This is very similar to issue #8898. Did you specifically require this implemented as a protocol handler, or would the solution proposed in #8898 be adequate?

@j4james commented on GitHub (Feb 6, 2021): This is very similar to issue #8898. Did you specifically require this implemented as a protocol handler, or would the solution proposed in #8898 be adequate?
Author
Owner

@awakecoding commented on GitHub (Feb 6, 2021):

@j4james very interesting, it looks like the other issue is very similar to this one, with the exception of the protocol handler. I wouldn't mark it as duplicate, because the protocol handler would be usable to open a new tab from a browser-based password manager (we have those as well), but then the requirements are different, and we'd have to see how to properly handle security for the dynamic command injection.

I suggest we modify this feature request to be the protocol handler built on top of the other issue #8898, rather than the entire feature by itself. The goal would be to securely expose the same functionality but through a protocol handler instead.

I have a few ideas how security could be handled:

  • the profile could be preconfigured with a hard-coded command, and the profile id would need to be known in advance
  • a security warning could be shown to the user and the entire command presented in a dialog box before running it
  • the command could be signed by a certificate using something very similar to .rdp file signatures. A modern variant would be a JWT

What do you think?

@awakecoding commented on GitHub (Feb 6, 2021): @j4james very interesting, it looks like the other issue is very similar to this one, with the exception of the protocol handler. I wouldn't mark it as duplicate, because the protocol handler would be usable to open a new tab from a browser-based password manager (we have those as well), but then the requirements are different, and we'd have to see how to properly handle security for the dynamic command injection. I suggest we modify this feature request to be the protocol handler built on top of the other issue #8898, rather than the entire feature by itself. The goal would be to securely expose the same functionality but through a protocol handler instead. I have a few ideas how security could be handled: - the profile could be preconfigured with a hard-coded command, and the profile id would need to be known in advance - a security warning could be shown to the user and the entire command presented in a dialog box before running it - the command could be signed by a certificate using something very similar to .rdp file signatures. A modern variant would be a JWT What do you think?
Author
Owner

@skyline75489 commented on GitHub (Feb 6, 2021):

This is what @zadjii-msft is recently working on.

@skyline75489 commented on GitHub (Feb 6, 2021): This is what @zadjii-msft is recently working on.
Author
Owner

@awakecoding commented on GitHub (Feb 6, 2021):

This is what @zadjii-msft is recently working on.

Got a link to a branch or related issue with the WIP code? 😲

@awakecoding commented on GitHub (Feb 6, 2021): > This is what @zadjii-msft is recently working on. Got a link to a branch or related issue with the WIP code? 😲
Author
Owner

@skyline75489 commented on GitHub (Feb 6, 2021):

There’s a bunch of related issues. For PR there’s #8898 , which may not be exact what you asked by is part of a grand plan.

@skyline75489 commented on GitHub (Feb 6, 2021): There’s a bunch of related issues. For PR there’s #8898 , which may not be exact what you asked by is part of a grand plan.
Author
Owner

@skyline75489 commented on GitHub (Feb 6, 2021):

Oh sorry about it. Didn’t noticed James already mentioned #8898. I was merely want to summon @zadjii-msft. Bet he has something to say about this issue.

@skyline75489 commented on GitHub (Feb 6, 2021): Oh sorry about it. Didn’t noticed James already mentioned #8898. I was merely want to summon @zadjii-msft. Bet he has something to say about this issue.
Author
Owner

@zadjii-msft commented on GitHub (Feb 8, 2021):

Hey thanks for the great write up here. I think for the majority of cases, the wt.exe sommandline args to invoke existing windows is going to be sufficient. However, you've got a great point about invoking the terminal from a browser window.

We've actually already started the discussion of a protocol handler over in #4842, so I'm gonna close this discussion as a dupe. I am going to make sure to call this thread out though, because it's got some great points. Thanks!

/dup #4842

@zadjii-msft commented on GitHub (Feb 8, 2021): Hey thanks for the great write up here. I think for the _majority_ of cases, the `wt.exe` sommandline args to invoke existing windows is going to be sufficient. However, you've got a great point about invoking the terminal from a browser window. We've actually already started the discussion of a protocol handler over in #4842, so I'm gonna close this discussion as a dupe. I am going to make sure to call this thread out though, because it's got some great points. Thanks! /dup #4842
Author
Owner

@ghost commented on GitHub (Feb 8, 2021):

Hi! We've identified this issue as a duplicate of another one that already exists on this Issue Tracker. This specific instance is being closed in favor of tracking the concern over on the referenced thread. Thanks for your report!

@ghost commented on GitHub (Feb 8, 2021): Hi! We've identified this issue as a duplicate of another one that already exists on this Issue Tracker. This specific instance is being closed in favor of tracking the concern over on the referenced thread. Thanks for your report!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#12440