Bug with "Open windows from a previous session" and defaults profile run as admin #19470

Open
opened 2026-01-31 06:44:15 +00:00 by claunia · 7 comments
Owner

Originally created by @Quenom on GitHub (Feb 28, 2023).

Windows Terminal version

1.16.10261.0

Windows build number

10.0.19045.2604

Other Software

No response

Steps to reproduce

Set "When Terminal Starts" to "open windows from a previous session"
Set Defaults to run this profile as administrator

Expected Behavior

When opening terminal from start menu it opens as administrator with saved tabs

Actual Behavior

Terminal opens with default profile and new window with previous tabs.
This happens even with saved tab being the startup default

Originally created by @Quenom on GitHub (Feb 28, 2023). ### Windows Terminal version 1.16.10261.0 ### Windows build number 10.0.19045.2604 ### Other Software _No response_ ### Steps to reproduce Set "When Terminal Starts" to "open windows from a previous session" Set Defaults to run this profile as administrator ### Expected Behavior When opening terminal from start menu it opens as administrator with saved tabs ### Actual Behavior Terminal opens with default profile and new window with previous tabs. This happens even with saved tab being the startup default
Author
Owner

@Quenom commented on GitHub (Feb 28, 2023):

I think it might be similar to #14861 and #14799
Could setting be added to run terminal itself as administrator, and not profiles? As there is no way to set default way microsoft store apps open

@Quenom commented on GitHub (Feb 28, 2023): I think it might be similar to #14861 and #14799 Could setting be added to run terminal itself as administrator, and not profiles? As there is no way to set default way microsoft store apps open
Author
Owner

@zadjii-msft commented on GitHub (Mar 1, 2023):

Okay I don't think we have a dupe for this after all. It's different enough from:

Though, it's ultimately the same nexus as all them

@zadjii-msft commented on GitHub (Mar 1, 2023): Okay I don't think we have a dupe for this after all. It's different enough from: * #13596 * #14442 * #13929 Though, it's ultimately the same nexus as all them
Author
Owner

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

I have this as well on the exact same specifications.

Expected behavior is that the old session starts (if "load previous session" is configured) 1:1 without any new windows or tabs UNLESS I exclusively tell it to do something else. :)

@mtaalas commented on GitHub (Jun 4, 2023): I have this as well on the exact same specifications. Expected behavior is that the old session starts (if "load previous session" is configured) 1:1 without any new windows or tabs UNLESS I exclusively tell it to do something else. :)
Author
Owner

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

I think I see the real issue in my case.

I've installed Terminal from windows store to get auto updates and it has created an app shortcut (or it's not really a shortcut in a normal sense) that calls the terminal with the following:

"c:\Program Files\WindowsApps\Microsoft.WindowsTerminal_(version)\windowsTerminal.exe" new-tab --profile [profile path]

So t's exclusively asking to launch a new tab when it's opened... but I've never set it up to do that.

I cannot change these parameters in any way.. it seems to be hard coded. I can only see this because it's trying to run as admin and I select "show details" on UAC prompt.

I'm still not sure what type of shortcut / program this is (I'm not familiar with windows store peculiarities) but these seem to come when you install the terminal using the store.

Can someone confirm or explain what's going on?

@mtaalas commented on GitHub (Jun 4, 2023): I think I see the real issue in my case. I've installed Terminal from windows store to get auto updates and it has created an app shortcut (or it's not really a shortcut in a normal sense) that calls the terminal with the following: "c:\Program Files\WindowsApps\Microsoft.WindowsTerminal_(version)\windowsTerminal.exe" new-tab --profile [profile path] So t's exclusively asking to launch a new tab when it's opened... but I've never set it up to do that. I cannot change these parameters in any way.. it seems to be hard coded. I can only see this because it's trying to run as admin and I select "show details" on UAC prompt. I'm still not sure what type of shortcut / program this is (I'm not familiar with windows store peculiarities) but these seem to come when you install the terminal using the store. Can someone confirm or explain what's going on?
Author
Owner

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

@mtaalas Sorry, just seeing that comment after getting back from leave.

That looks to me like you've got the Terminal set up to run your default profile elevated (as admin) by default. In that case, when you launch the Terminal unelevated, it needs to explicitly shell out to create another new instance of the Terminal as admin. When that happens, it explicitly passes new-tab -p {{profile_guid}} as the args, so that the new terminal window gets created with the correct profile.

Now, maybe there's an easy solution here - when the Terminal is getting launched elevated for the default profile, maybe we shouldn't pass those args? That'd cause the Terminal to start up, and either

  • use the ELEVATED windows from last time, if there are any (and that setting is turned on)
  • just make a single window with the default profile (elevated)

Right now, because we are passing the new-tab -p {{blah}}, that tells the terminal EXPLICITLY "I want something new ({{blah}}), also, bring back what I had before"

@zadjii-msft commented on GitHub (Jul 24, 2023): @mtaalas Sorry, just seeing that comment after getting back from leave. That looks to me like you've got the Terminal set up to run your default profile elevated (as admin) by default. In that case, when you launch the Terminal _unelevated_, it needs to explicitly shell out to create _another_ new instance of the Terminal as admin. When that happens, it explicitly passes `new-tab -p {{profile_guid}}` as the args, so that the new terminal window gets created with the correct profile. Now, maybe there's an easy solution here - when the Terminal is getting launched elevated for the default profile, maybe we shouldn't pass those args? That'd cause the Terminal to start up, and either * use the ELEVATED windows from last time, if there are any (and that setting is turned on) * just make a single window with the default profile (elevated) Right now, because we _are_ passing the `new-tab -p {{blah}}`, that tells the terminal EXPLICITLY "I want something _new_ ({{blah}}), also, bring back what I had before"
Author
Owner

@Serat00l951 commented on GitHub (Mar 2, 2024):

Hello guys. Is there any ETA of fixing this bug? I have encountered this bug in 1.17 (#15738) and it still exists in 1.19.

@Serat00l951 commented on GitHub (Mar 2, 2024): Hello guys. Is there any ETA of fixing this bug? I have encountered this bug in 1.17 (#15738) and it still exists in 1.19.
Author
Owner

@foxtrottNB commented on GitHub (Apr 29, 2025):

Hello guys. Is there any ETA of fixing this bug?

@foxtrottNB commented on GitHub (Apr 29, 2025): Hello guys. Is there any ETA of fixing this bug?
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#19470