Powershell: Console window remains open when VSCode started from PowerShell

Created on 9 Jan 2020  路  5Comments  路  Source: PowerShell/PowerShell

Tracked in VSCode as https://github.com/microsoft/vscode/issues/50308.

Steps to reproduce

(On Windows)

  • Open VSCode with code .
  • exit PowerShell

Expected behavior

  • PowerShell console window closes
  • VSCode stays open

Actual behavior

  • PowerShell window remains open
  • VSCode remains open
  • When VSCode window is closed, the PowerShell window is closed
  • If PowerShell runs code but does not open a new window (because one for the directory is already open) the issue does not occur

Environment data


Name                           Value
----                           -----
PSVersion                      7.0.0-rc.1
PSEdition                      Core
GitCommitId                    7.0.0-rc.1
OS                             Microsoft Windows 10.0.19535
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0鈥
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0


Issue-Question Resolution-External WG-Engine

Most helpful comment

There's nothing PowerShell can do to prevent this. VSCode (<=1.41? to be confirmed) _re-attaches to the console handle it receives from its parent_. In so doing, it prevents the console from being closed when PowerShell exits because there's still one application attached to it.

All 5 comments

This is microsoft/vscode#66750.

PowerShell try to detect that application is GUI then run it async. Otherwise it run the application as console application in sync.

See #9970 for reference on IsWindowsApplication()

There's nothing PowerShell can do to prevent this. VSCode (<=1.41? to be confirmed) _re-attaches to the console handle it receives from its parent_. In so doing, it prevents the console from being closed when PowerShell exits because there's still one application attached to it.

This issue has been marked as external and has not had any activity for 1 day. It has been be closed for housekeeping purposes.

Was this page helpful?
0 / 5 - 0 ratings