Clicking shortcut to WT PowerShell profile opens 2 windows #19328

Open
opened 2026-01-31 06:40:16 +00:00 by claunia · 11 comments
Owner

Originally created by @WillPittenger on GitHub (Feb 6, 2023).

Windows Terminal version

1.16.10261.0

Windows build number

Edition Windows 11 Pro Version 22H2 Installed on ‎12-‎8-‎2022 OS build 22621.1194 Experience Windows Feature Experience Pack 1000.22638.1000.0

Other Software

PowerShell 7.3.2

Steps to reproduce

1 Create a Windows shortcut with the command line C:\Users\willp\AppData\Local\Microsoft\WindowsApps\wt.exe -p "PowerShell"
2 Create a matching WT profile
3 Click the shortcut

How many windows opened?

Expected Behavior

I'd expect only at most one new window.

Actual Behavior

With no WT widows open, I get two to the same profile.

Originally created by @WillPittenger on GitHub (Feb 6, 2023). ### Windows Terminal version 1.16.10261.0 ### Windows build number Edition Windows 11 Pro Version 22H2 Installed on ‎12-‎8-‎2022 OS build 22621.1194 Experience Windows Feature Experience Pack 1000.22638.1000.0 ### Other Software PowerShell 7.3.2 ### Steps to reproduce 1 Create a Windows shortcut with the command line `C:\Users\willp\AppData\Local\Microsoft\WindowsApps\wt.exe -p "PowerShell"` 2 Create a matching WT profile 3 Click the shortcut How many windows opened? ### Expected Behavior I'd expect only at most one new window. ### Actual Behavior With no WT widows open, I get two to the same profile.
claunia added the Area-SettingsIssue-BugProduct-TerminalPriority-2 labels 2026-01-31 06:40:16 +00:00
Author
Owner

@lhecker commented on GitHub (Feb 7, 2023):

Are you sure you have 1.16.10261 installed? That's the version for Windows 10. You can replace it with 1.16.10262 from here.

Additionally I'm not sure how your 1. and 2. step fit together: The "PowerShell" profile is a standard profile and should always exist unless you deleted it previously. Is "PowerShell" in your first step just an example or is the 2. step optional?


Interesting... I can't reproduce this behavior with 1.16.10262.0 and PowerShell 7.3.2. What happens if you add -NoProfile to the command line of your "PowerShell" profile? If that doesn't fix the issue, could you share your settings.json?

@lhecker commented on GitHub (Feb 7, 2023): Are you sure you have 1.16.10261 installed? That's the version for Windows 10. You can replace it with [1.16.10262 from here](https://github.com/microsoft/terminal/releases/tag/v1.16.10261.0). Additionally I'm not sure how your 1. and 2. step fit together: The "PowerShell" profile is a standard profile and should always exist unless you deleted it previously. Is "PowerShell" in your first step just an example or is the 2. step optional? --- Interesting... I can't reproduce this behavior with 1.16.10262.0 and PowerShell 7.3.2. What happens if you add `-NoProfile` to the command line of your "PowerShell" profile? If that doesn't fix the issue, could you share your [settings.json](https://github.com/microsoft/terminal/wiki/Frequently-Asked-Questions-(FAQ)#where-can-i-find-the-settings-file)?
Author
Owner

@WillPittenger commented on GitHub (Feb 7, 2023):

It's proving to be intermittent. Yes, that's the version I see installed. I copied the version number from the About dialog.
image

@WillPittenger commented on GitHub (Feb 7, 2023): It's proving to be intermittent. Yes, that's the version I see installed. I copied the version number from the About dialog. ![image](https://user-images.githubusercontent.com/5451058/217269066-63dab55c-e385-4fb8-b897-6019ae841f96.png)
Author
Owner

@DHowett commented on GitHub (Feb 7, 2023):

Do you, by chance, have this setting set?

image
@DHowett commented on GitHub (Feb 7, 2023): Do you, by chance, have this setting set? <img width="770" alt="image" src="https://user-images.githubusercontent.com/189190/217328892-031daa41-d70f-42da-9960-3fa0615aafb0.png">
Author
Owner

@WillPittenger commented on GitHub (Feb 7, 2023):

I have "Open Windows from a previous session". That might be it. I was hoping to see my previous PS session.

@WillPittenger commented on GitHub (Feb 7, 2023): I have "Open Windows from a previous session". That might be it. I was hoping to see my previous PS session.
Author
Owner

@carlos-zamora commented on GitHub (Feb 8, 2023):

Did this turn out to be your issue?

@carlos-zamora commented on GitHub (Feb 8, 2023): Did this turn out to be your issue?
Author
Owner

@akbyrd commented on GitHub (Feb 12, 2023):

I've run into this as well. Using "firstWindowPreference": "persistedWindowLayout" causes Windows Terminal to open multiple windows, depending on the command line used to launch it.

wt -d . will open 2 windows. One with the previous session and a new one with a shell window for the current directory.

I think the expected behavior here is that a single window is opened with the previous session and a new shell instance is added to that window.

wt -p "PowerShell" has the same issue.

Version 1.16.10261.0 on Windows 10

@akbyrd commented on GitHub (Feb 12, 2023): I've run into this as well. Using `"firstWindowPreference": "persistedWindowLayout"` causes Windows Terminal to open multiple windows, depending on the command line used to launch it. `wt -d .` will open 2 windows. One with the previous session and a new one with a shell window for the current directory. I think the expected behavior here is that a single window is opened with the previous session and a new shell instance is added to that window. `wt -p "PowerShell"` has the same issue. Version 1.16.10261.0 on Windows 10
Author
Owner

@zadjii-msft commented on GitHub (Feb 13, 2023):

Yea, this is just kinda by-design for now. If you don't have any Terminal windows open, and have "firstWindowPreference": "persistedWindowLayout" set, and run a wt commandline that's not just wt.exe (e.g. wt -d .), then we'll open up the old windows, AND open the new thing you've asked for (in this case, the new-tab -d .). This is roughly consistent with how browsers work, if you did something like edge.exe github.com without any windows currently open.

I suppose theoretically, this could also respect the "windowingBehavior" setting. If that was set to use*Existing, then theoretically I suppose we should append the passed commandline to whatever commandline we're going to restore from. That would make sense.

I'll leave this open, on the backlog. I've been playing in the state restoration code quite a bit recently, and I don't think this would be super easy to fix...

@zadjii-msft commented on GitHub (Feb 13, 2023): Yea, this is just kinda by-design for now. If you don't have any Terminal windows open, **and** have `"firstWindowPreference": "persistedWindowLayout"` set, **and** run a wt commandline that's not _just_ `wt.exe` (e.g. `wt -d .`), then we'll open up the old windows, AND open the new thing you've asked for (in this case, the `new-tab -d .`). This is roughly consistent with how browsers work, if you did something like `edge.exe github.com` without any windows currently open. I suppose theoretically, this could also respect the `"windowingBehavior"` setting. If that was set to `use*Existing`, then theoretically I suppose we should append the passed commandline to whatever commandline we're going to restore from. That would make sense. I'll leave this open, on the backlog. I've been playing in the state restoration code quite a bit recently, and I don't think this would be super easy to fix...
Author
Owner

@akbyrd commented on GitHub (Feb 13, 2023):

Just as a data point one place where this comes up naturally is vscode. When it launches an external terminal it passes the current directory. I don't think this is configurable by the user, but it's the desired behavior in any case.

Respecting windowingBehavior makes sense to me, personally, and would be desirable.

@akbyrd commented on GitHub (Feb 13, 2023): Just as a data point one place where this comes up naturally is vscode. When it launches an external terminal it passes the current directory. I don't think this is configurable by the user, but it's the desired behavior in any case. Respecting `windowingBehavior` makes sense to me, personally, and would be desirable.
Author
Owner

@aderchox commented on GitHub (May 27, 2023):

I had the same issue and I initially (naively confused!) thought this was VSCode's issue.
I've added a GIF at: https://github.com/microsoft/vscode/issues/183401
I think it's annoying in case of VSCode and makes such a brilliant option (open external terminal) useless. My laptop screen is small and I tend to use the external terminal rather than the integrated one, but everytime I re-open the external terminal, I have to close the extra one.
Another similar issue has also been added at: https://github.com/microsoft/terminal/issues/14932

Based on what I've read here, the current behavior is respecting some conventions, but I guess you might be able to add some third option or a flag? Then that flag might be usable in VSCode default terminal settings (I've not tested this though).

@aderchox commented on GitHub (May 27, 2023): I had the same issue and I initially (naively confused!) thought this was VSCode's issue. I've added a GIF at: https://github.com/microsoft/vscode/issues/183401 I think it's annoying in case of VSCode and makes such a brilliant option (open external terminal) useless. My laptop screen is small and I tend to use the external terminal rather than the integrated one, but everytime I re-open the external terminal, I have to close the extra one. Another similar issue has also been added at: https://github.com/microsoft/terminal/issues/14932 Based on what I've read here, the current behavior is respecting some conventions, but I guess you might be able to add some third option or a flag? Then that flag _might_ be usable in VSCode default terminal settings (I've not tested this though).
Author
Owner

@mtaalas commented on GitHub (Jun 4, 2023):

My expected behavior is also, that if I use default Start Menu shortcut (that Windows store created when installing Terminal) to launch the Terminal, it'll restore my old session as/if configured from the settings to do so, but does NOT open anything else UNLESS I specifically tell it to with separate arguments. And there's a lot of different possibilities:

There's a difference choosing between these things:

Open previous session tabs and windows
Open previous session and ATTACH the new window as a tab to the previous session window
Open previous session and open this new shell/terminal as a new window
Open new window and discard old session

It's many things and possibilities and as it stands it doesn't seem to be very exclusive in how to handle it properly.

From browsers I've come to expect (and from notepad++ for that matter) that launching the application itself without arguments doesn't automatically open new tab or window, it either restores my old session 1:1 OR starts from scratch depending what configuration was active. If I want to open extra tab/window to a location, I should explicitly command it to do so.

As a user, I expect it to open to the last window I used in the session that's being restored (let's say session had 3 windows, if I was using specific window before closing the session [based on what window was in focus?], THAT'S the one I expect the new tab to open to), unless I specifically have an option to choose where it opens to based on arguments or profile configuration.

Like in NPP, It opens all the previous tabs AND it'll attach the new file that I gave as an argument to the end of that tab list.

I hope you'll figure it out... it's not an easy problem by any means to tackle. :)

@mtaalas commented on GitHub (Jun 4, 2023): My expected behavior is also, that if I use default Start Menu shortcut (that Windows store created when installing Terminal) to launch the Terminal, it'll restore my old session as/if configured from the settings to do so, but does NOT open anything else UNLESS I specifically tell it to with separate arguments. And there's a lot of different possibilities: There's a difference choosing between these things: Open previous session tabs and windows Open previous session and ATTACH the new window as a tab to the previous session window Open previous session and open this new shell/terminal as a new window Open new window and discard old session It's many things and possibilities and as it stands it doesn't seem to be very exclusive in how to handle it properly. From browsers I've come to expect (and from notepad++ for that matter) that launching the application itself without arguments doesn't automatically open new tab or window, it either restores my old session 1:1 OR starts from scratch depending what configuration was active. If I want to open extra tab/window to a location, I should explicitly command it to do so. As a user, I expect it to open to the last window I used in the session that's being restored (let's say session had 3 windows, if I was using specific window before closing the session [based on what window was in focus?], THAT'S the one I expect the new tab to open to), unless I specifically have an option to choose where it opens to based on arguments or profile configuration. Like in NPP, It opens all the previous tabs AND it'll attach the new file that I gave as an argument to the end of that tab list. I hope you'll figure it out... it's not an easy problem by any means to tackle. :)
Author
Owner

@zadjii commented on GitHub (Jun 4, 2023):

Guys what if we restored both the unelevated and the elevated windows when either are launched?

@zadjii commented on GitHub (Jun 4, 2023): Guys what if we restored both the unelevated and the elevated windows when either are launched?
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#19328