Vscode, integrated terminal not launching powershell / gitbash / cmd.
This error occurs in less privileged (normal AD/LDAP user) account but it works only if I launch VSCode as an administrator.
Same error occurs even after disabling the Antivirus program.
Error : The terminal process command 'C:\WINDOWS\System32\WindowsPowerShell\v1.0\powershell.exe' failed to launch (exit code: {2})
The terminal process command 'C:\Program Files\Git\bin\bash.exe' failed to launch (exit code: {2})
'C:\WINDOWS\System32\cmd.exe' failed to launch (exit code: {2})
Platform:
Windows 10E
Version: 1903
OS build 18362.535

Also, the path is weird. It should be Windows not WINDOWS. Correcting that in settings.json too didn't work. Tried with 64 bit, 32 bit, User and System wide installations too. But no dice.
BTW those terminals launch normally if I open them outside of VSCode. Also the project path exists, no weird symbol in pathname, even tried launching the vscode without opening any project. But the issue persists since December 31, 2019.
Tried escaping space in file path as recommended in following wiki. But still no luck.
https://github.com/cmderdev/cmder/wiki/Seamless-VS-Code-Integration
{
// "terminal.integrated.shell.windows": "C:\Program^ Files\Git\bin\bash.exe",
"terminal.integrated.shell.windows": "C:\PROGRA~1\Git\bin\bash.exe"
}

Ohh man! I fixed the issue by opting-out / disabling the Conpty in settings.json.
{
// "terminal.integrated.shell.windows": "C:\Program^ Files\Git\bin\bash.exe",
"terminal.integrated.shell.windows": "C:\WINDOWS\System32\WindowsPowerShell\v1.0\powershell.exe",
"terminal.integrated.windowsEnableConpty": false
}
This linked helped me solve the issue. Thanks to @Tyriar
https://github.com/microsoft/vscode/issues/45693
Note that by doing so you're moving back to the legacy system winpty that isn't supported anymore. Do you have any issues like this creating terminals in Windows Terminal? https://www.microsoft.com/en-us/p/windows-terminal-preview/9n0dx20hk701?activetab=pivot:overviewtab
@Tyriar I found that to be a Preview version, so I chose to fall back to Winpty. Since you have instructed to go with the new terminal app, I will let you know the status once I get it installed & tested.. Thank you for guiding me..
@Tyriar: Until I get that new terminal app (preview) and tested out, could you please clarify on my open question in line #2 and below inquiry as well.
@Tyriar:
Tried download & install the New terminal app + dependency but got the following error when I ran it.

Will test the other way (from store) and will let you know.
Apparently, the problem started post recent windows os patch.
If the absence of Conpty is the reason for the terminals to crash then how did those terminals launch from an elevated account in the first place.
Conpty is the reason it's not working, not the other way around.
BTW, why did WinPty become legacy when the replacement is just in Preview stage !?
Windows Terminal is preview, conpty is not.
Apparently, the problem started post recent windows os patch.
Your Windows 10 version is the one that conpty was turned on by default in VS Code. Changing to disable that will go back to what you were on before.
https://github.com/microsoft/vscode/issues/86432 is suggesting that this is likely due to anti-virus/malware software, do you have one of those active?
Ours is not due to #86432. Ours is error code {2} and I even tried launching terminals after disabling the AV but still faced the issue. In my circle, until we get that new terminal app installed from the store & tested, we use either disabling conpty in settings.json or launching the vscode as admin. Either way it works as a work-around. Time being, I'm fine with the work-around and may use the new terminal app once it's production (not a preview version). Another concern is that, I'm again started seeing the weird grey background on ipython in integrated terminal. The solution that I followed and worked earlier (by setting "dom" for rendererType is not working now. Any resolution for this would be appreciated as I'm having hardtime to read text and background of same color in ipython opened in integrated terminal.
{ "terminal.integrated.rendererType": "dom", }
@miniksa is it expected to not be able to use conpty in "less privileged (normal AD/LDAP user) accounts"? It's working when @arjunkayalabi runs VS Code as admin.
You should be able to run it as a normal user on an account with a split token (one that can elevate to Administrator privileges via UAC but runs things as MediumIL/normal usually).
I'm not totally clear on what "less privileged (normal AD/LDAP user)" means.
@miniksa
Meaning, normal user accounts created via Windows Active Directory (AD / LDAP). So, the work-around is either by disabling conpty in vscode's settings.json or login to windows as a normal user (AD) and launch the vscode as an Administrator (which is also an AD account but with admin / elevated access).
The question here is why can't we launch it as a normal user? why do we need an elevated access to launch vscode + conpty.
@Tyriar if you are closing issues and directing them here what additional information can I provide.
@lbrown1591 actually i'll reopen yours and continue the discussion there as you're on an older version of windows using a different backend.
Having the same issue on Company AD Windows 10, what is the suggested/long term suggestion for this? I think we need a default that works for all installations (as previously).
By the way WSL terminal is working fine without elevated priviliges.
Sorry I did not check correctly, I'm still on 17134.1184 and have the issue regardless of the conpty setting.
EDIT: here is the error from the trace log
[2020-01-16 10:50:08.145] [renderer1] [debug] Terminal process exit (id: 1) with code Error: Error launching WinPTY agent: agent died
[2020-01-16 10:50:08.145] [renderer1] [debug] Terminal process exit (id: 1) state 3
EDIT2: It does work when launched with elevated priviliges. I also noticed that without elevated priviliges I can not create a C# debug config or start the debugger (it just hangs).
@PaulFreund we've largely stopped supporting winpty in favor of conpty which is built by the Windows console team. Upgrading to 1903 (build number 18362+) will move you onto the new backend.
@Tyriar I do understand and support your decision bit being in a corporate installation rollout is quite slow. I will have to find out which is the last working version and hope compatibility does not break somewhere else until then.
If you are using Malwarebytes (like I am) it may be causing this problem for you too, if so then adding the Microsoft VS Code folder to your Allow List may fix your problem as it did for me.
I was having the same issue here with Windows PowerShell/CMD not running inside of VS Code. Adding the Microsoft VS Code folder to the allow list within Malwarebytes fixed it for me - I searched forever this fix. Thanks @bgree052
I work in a corporate environment. The terminal exits due to security software installed and enforced, blocking certain executables from running from a user profile. If VSC could expose a setting to change the conpty\winpty executable path, I could point it at the winpty exe supplied by git-bash installed to program files. Git-bash winpty does execute in my environment.
I had the same issue due to Software Restriction Policy:
- <Event xmlns="http://schemas.microsoft.com/win/2004/08/events/event">
- <System>
<Provider Name="Microsoft-Windows-SoftwareRestrictionPolicies" Guid="{7d29d58a-931a-40ac-8743-48c733045548}" />
<EventID>865</EventID>
<Version>0</Version>
<Level>3</Level>
<Task>0</Task>
<Opcode>0</Opcode>
<Keywords>0x8000000000000000</Keywords>
<TimeCreated SystemTime="2020-04-07T15:40:14.459859200Z" />
<EventRecordID>2341</EventRecordID>
<Correlation />
<Execution ProcessID="232" ThreadID="11952" />
<Channel>Application</Channel>
<Computer>DESKTOP-1HPHUJC</Computer>
<Security UserID="S-1-5-21-3162574618-1024451937-3568532052-1001" />
</System>
- <UserData>
- <Path xmlns="http://schemas.microsoft.com/schemas/event/Microsoft.Windows/1.0.0.0">
<AttemptedPath>\\?\C:\Windows\system32\conhost.exe</AttemptedPath>
</Path>
</UserData>
</Event>
This was unexpected because the policy whitelists %HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\SystemRoot%. Fixed it by hadding a hash rule for conhost.exe. Version information:
Version: 1.43.2 (system setup)
Commit: 0ba0ca52957102ca3527cf479571617f0de6ed50
Date: 2020-03-24T07:38:38.248Z
Electron: 7.1.11
Chrome: 78.0.3904.130
Node.js: 12.8.1
V8: 7.8.279.23-electron.0
OS: Windows_NT x64 10.0.18363
Most helpful comment
Ohh man! I fixed the issue by opting-out / disabling the Conpty in settings.json.
{
// "terminal.integrated.shell.windows": "C:\Program^ Files\Git\bin\bash.exe",
"terminal.integrated.shell.windows": "C:\WINDOWS\System32\WindowsPowerShell\v1.0\powershell.exe",
"terminal.integrated.windowsEnableConpty": false
}
This linked helped me solve the issue. Thanks to @Tyriar
https://github.com/microsoft/vscode/issues/45693