I would like to open Visual Studio Code for a specific folder, the command works I try to run, but when the script opens VSCode, it doesn't close the PowerShell window. I would like to close the PowerShell window right after the Script opens the VSCode. But even an explicit exit call does not work:
ii F:\c#
iex "& code ."
exit
This opens VSCode, but the Shell Window stays open until I close VSCode.
This is the bug in the VS Code's backend. It unnecessary attaches itself to the console window preventing it to close even after shell application quit.
It actually not related to PowerShell. You will get the same behavior with .bat
/.cmd
file, which contains single code
command. If you double-click it in explorer, then console windows will not close until you close VS Code, even though in task manager you can see, that CMD
instance used to execute .bat
/.cmd
file no longer exists.
To workaround this bug you can create new hidden console window for VS Code to attach to, instead of console window of your PowerShell instance:
Start-Process -WindowStyle Hidden code .
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With