Shell unexpectedly exits or crashes when elevating a new PowerShell instance. #10588

Closed
opened 2026-01-31 02:25:15 +00:00 by claunia · 4 comments
Owner

Originally created by @daniefer on GitHub (Sep 10, 2020).

Environment

Windows build number:

PS >[Environment]::OSVersion
Platform ServicePack Version      VersionString
-------- ----------- -------      -------------
 Win32NT             10.0.19041.0 Microsoft Windows NT 10.0.19041.0

Windows Terminal version (if applicable):

image

Any other software?

PS > $PSVersionTable

Name                           Value
----                           -----
PSVersion                      5.1.19041.1
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.19041.1
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1

PS > $PSHOME
C:\Windows\System32\WindowsPowerShell\v1.0

Steps to reproduce

  1. Run the command Start-Process PowerShell -Verb RunAs "-NoProfile -ExecutionPolicy Bypass -Command `"cd '$pwd'; & echo hello world`"";
  2. Approve the windows prompt for elevation
  3. Repeat steps 1 and 2 between 2-5 times in a row
  4. The host tab will close even though the user did not exist the shell.

This was discovered with an auto elevating script such as this example. The script will run 1 or 2 times and then the host Windows Terminal tab will close unexpectedly. I have tried replicating with other shells with no luck. I am not certain this is only a PowerShell issue.

Expected behavior

The user should be able to run the command Start-Process PowerShell -Verb RunAs "-NoProfile -ExecutionPolicy Bypass -Command `"cd '$pwd'; & echo hello world`""; any number of times and not have Windows Terminal close the tab.

Actual behavior

Run the command Start-Process PowerShell -Verb RunAs "-NoProfile -ExecutionPolicy Bypass -Command `"cd '$pwd'; & echo hello world`""; between 2-5 times in a row and the host tab will close.

Originally created by @daniefer on GitHub (Sep 10, 2020). <!-- 🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨 I ACKNOWLEDGE THE FOLLOWING BEFORE PROCEEDING: 1. If I delete this entire template and go my own path, the core team may close my issue without further explanation or engagement. 2. If I list multiple bugs/concerns in this one issue, the core team may close my issue without further explanation or engagement. 3. If I write an issue that has many duplicates, the core team may close my issue without further explanation or engagement (and without necessarily spending time to find the exact duplicate ID number). 4. If I leave the title incomplete when filing the issue, the core team may close my issue without further explanation or engagement. 5. If I file something completely blank in the body, the core team may close my issue without further explanation or engagement. All good? Then proceed! --> <!-- This bug tracker is monitored by Windows Terminal development team and other technical folks. **Important: When reporting BSODs or security issues, DO NOT attach memory dumps, logs, or traces to Github issues**. Instead, send dumps/traces to secure@microsoft.com, referencing this GitHub issue. If this is an application crash, please also provide a Feedback Hub submission link so we can find your diagnostic data on the backend. Use the category "Apps > Windows Terminal (Preview)" and choose "Share My Feedback" after submission to get the link. Please use this form and describe your issue, concisely but precisely, with as much detail as possible. --> # Environment Windows build number: ```none PS >[Environment]::OSVersion Platform ServicePack Version VersionString -------- ----------- ------- ------------- Win32NT 10.0.19041.0 Microsoft Windows NT 10.0.19041.0 ``` Windows Terminal version (if applicable): ![image](https://user-images.githubusercontent.com/5559147/92771242-54014200-f360-11ea-91c1-196e901367e2.png) Any other software? ```none PS > $PSVersionTable Name Value ---- ----- PSVersion 5.1.19041.1 PSEdition Desktop PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...} BuildVersion 10.0.19041.1 CLRVersion 4.0.30319.42000 WSManStackVersion 3.0 PSRemotingProtocolVersion 2.3 SerializationVersion 1.1.0.1 PS > $PSHOME C:\Windows\System32\WindowsPowerShell\v1.0 ``` # Steps to reproduce 1. Run the command ``Start-Process PowerShell -Verb RunAs "-NoProfile -ExecutionPolicy Bypass -Command `"cd '$pwd'; & echo hello world`"";`` 1. Approve the windows prompt for elevation 1. Repeat steps 1 and 2 between 2-5 times in a row 1. The host tab will close even though the user did not exist the shell. <!-- A description of how to trigger this bug. --> This was discovered with an auto elevating script such as [this example](https://stackoverflow.com/a/57035712). The script will run 1 or 2 times and then the host Windows Terminal tab will close unexpectedly. I have tried replicating with other shells with no luck. I am not certain this is only a PowerShell issue. # Expected behavior The user should be able to run the command ``Start-Process PowerShell -Verb RunAs "-NoProfile -ExecutionPolicy Bypass -Command `"cd '$pwd'; & echo hello world`"";`` any number of times and not have Windows Terminal close the tab. <!-- A description of what you're expecting, possibly containing screenshots or reference material. --> # Actual behavior Run the command ``Start-Process PowerShell -Verb RunAs "-NoProfile -ExecutionPolicy Bypass -Command `"cd '$pwd'; & echo hello world`"";`` between 2-5 times in a row and the host tab will close. <!-- What's actually happening? -->
claunia added the Needs-TriageNeeds-Tag-FixNeeds-Attention labels 2026-01-31 02:25:15 +00:00
Author
Owner

@DHowett commented on GitHub (Sep 11, 2020):

If you set closeOnExit to "never" for that profile, what do you see when it exits?

@DHowett commented on GitHub (Sep 11, 2020): If you set `closeOnExit` to `"never"` for that profile, what do you see when it exits?
Author
Owner

@daniefer commented on GitHub (Sep 11, 2020):

Windows PowerShell
Copyright (C) Microsoft Corporation. All rights reserved.

Try the new cross-platform PowerShell https://aka.ms/pscore6

PS > Start-Process PowerShell -Verb RunAs "-NoProfile -ExecutionPolicy Bypass -Command `"cd '$pwd'; & echo hello`"";
PS > Start-Process PowerShell -Verb RunAs "-NoProfile -ExecutionPolicy Bypass -Command `"cd '$pwd'; & echo hello`"";
PS > Start-Process PowerShell -Verb RunAs "-NoProfile -ExecutionPolicy Bypass -Command `"cd '$pwd'; & echo hello`"";
PS >
[process exited with code 0]
@daniefer commented on GitHub (Sep 11, 2020): ```none Windows PowerShell Copyright (C) Microsoft Corporation. All rights reserved. Try the new cross-platform PowerShell https://aka.ms/pscore6 PS > Start-Process PowerShell -Verb RunAs "-NoProfile -ExecutionPolicy Bypass -Command `"cd '$pwd'; & echo hello`""; PS > Start-Process PowerShell -Verb RunAs "-NoProfile -ExecutionPolicy Bypass -Command `"cd '$pwd'; & echo hello`""; PS > Start-Process PowerShell -Verb RunAs "-NoProfile -ExecutionPolicy Bypass -Command `"cd '$pwd'; & echo hello`""; PS > [process exited with code 0] ```
Author
Owner

@daniefer commented on GitHub (Sep 11, 2020):

I was able to reproduce this in PowerShell v7 and v5 terminals. So this might not be a WT problem. I also noticed this morning that this might be related to an overly aggressive antivirus. I will post again/reopen if that proves not to be the case.

@daniefer commented on GitHub (Sep 11, 2020): I was able to reproduce this in PowerShell v7 and v5 terminals. So this might not be a WT problem. I also noticed this morning that this might be related to an overly aggressive antivirus. I will post again/reopen if that proves not to be the case.
Author
Owner

@DHowett commented on GitHub (Sep 11, 2020):

Ah! Thanks for following up. 😄

@DHowett commented on GitHub (Sep 11, 2020): Ah! Thanks for following up. :smile:
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#10588