Existing window restored when Terminal is opened as a default terminal #20171

Closed
opened 2026-01-31 07:05:39 +00:00 by claunia · 4 comments
Owner

Originally created by @krzysdz on GitHub (Jul 1, 2023).

Windows Terminal version

94e6b91c78

Windows build number

10.0.19045.3086

Other Software

cmd.exe, powershell.exe or any .bat file to start cmd - anything that opens a terminal.

Steps to reproduce

  1. Make Windows Terminal the Default terminal application in settings.
  2. Make sure that New instance behavior is Create a new window.
  3. Set "firstWindowPreference": "persistedWindowLayout" (When Terminal starts: Open windows from a previous session)
  4. Open a few tabs.
  5. Open a .bat file from explorer or start cmd/powershell from the start menu or Win+R.

If opening .bat files behaves as expected, close all Terminal windows, open it again and try running .bat once more. It makes the issue reappear if for some reason it starts working correctly.

Expected Behavior

A new window opens, in which the file is executed.

Actual Behavior

Two new windows open:

  • one in which the file is executed
  • one with the same tabs as in the existing window

https://github.com/microsoft/terminal/assets/12915102/69f12b60-295a-4039-9b1e-acf864d29cf3

Originally created by @krzysdz on GitHub (Jul 1, 2023). ### Windows Terminal version 94e6b91c7892b9e2ec8244ab7990ecf50679b083 ### Windows build number 10.0.19045.3086 ### Other Software `cmd.exe`, `powershell.exe` or any `.bat` file to start `cmd` - anything that opens a terminal. ### Steps to reproduce 1. Make Windows Terminal the *Default terminal application* in settings. 2. Make sure that *New instance behavior* is *Create a new window*. 3. Set `"firstWindowPreference": "persistedWindowLayout"` (*When Terminal starts: Open windows from a previous session*) 4. Open a few tabs. 5. Open a `.bat` file from explorer or start `cmd`/`powershell` from the start menu or Win+R. If opening `.bat` files behaves as expected, close all Terminal windows, open it again and try running `.bat` once more. It makes the issue reappear if for some reason it starts working correctly. ### Expected Behavior A new window opens, in which the file is executed. ### Actual Behavior Two new windows open: - one in which the file is executed - one with the same tabs as in the existing window https://github.com/microsoft/terminal/assets/12915102/69f12b60-295a-4039-9b1e-acf864d29cf3
Author
Owner

@zadjii-msft commented on GitHub (Jul 6, 2023):

what

@zadjii-msft commented on GitHub (Jul 6, 2023): _what_
Author
Owner

@krzysdz commented on GitHub (Jul 6, 2023):

I think it may have something to do with #15509, because process explorer shows two different Terminal process trees:

The older Terminal - under explorer.exe (1 window):
Windows Terminal from explorer.exe

The reopened Terminal - under wininit.exe -> services.exe -> svhost.exe (2 windows - cmd and reopened):
Windows Terminal from svchost.exe

The cmd.exe launched from Win+R, which caused Terminal to start again is under explorer.exe:
cmd.exe

@krzysdz commented on GitHub (Jul 6, 2023): I think it may have something to do with #15509, because process explorer shows two different Terminal process trees: The *older* Terminal - under `explorer.exe` (1 window): ![Windows Terminal from explorer.exe](https://github.com/microsoft/terminal/assets/12915102/cfe13f0e-9663-4be8-8714-99f715a61995) The reopened Terminal - under `wininit.exe` -> `services.exe` -> `svhost.exe` (2 windows - cmd and reopened): ![Windows Terminal from svchost.exe](https://github.com/microsoft/terminal/assets/12915102/c9945f33-d7e8-4d04-9dae-b0e35d7f5415) The `cmd.exe` launched from Win+R, which caused Terminal to start again is under `explorer.exe`: ![cmd.exe](https://github.com/microsoft/terminal/assets/12915102/f3ca2c3b-a780-4b6f-b559-bc315c6c22d7)
Author
Owner

@zadjii-msft commented on GitHub (Jul 6, 2023):

Ah yep okay, hadn't seen that thread yet. That's definitely the same one. Thanks!

/dup #15509

@zadjii-msft commented on GitHub (Jul 6, 2023): Ah yep okay, hadn't seen that thread yet. That's definitely the same one. Thanks! /dup #15509
Author
Owner

@microsoft-github-policy-service[bot] commented on GitHub (Jul 6, 2023):

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!

@microsoft-github-policy-service[bot] commented on GitHub (Jul 6, 2023): 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#20171