8

Suddenly I started to get the next error message when trying to open the PowerShell Terminal window in VSCode:

The terminal process failed to launch: A native exception occurred during launch (Cannot create process, error code: 740).

What is the reason for it?

(There are similar questions on SO, but with other error codes, which are not helpful)

2 Answers 2

21

Here is a similar question on GitHub. In short, the problem is in pwsh.exe → Properties → 'Compatibility' tab → 'Run this program as an administrator' setting. In my case pwsh.exe is C:\Program Files\PowerShell\7\pwsh.exe

You can fix it in two ways:

  1. Run Visual Studio Code as Administrator (which is not always a good option)
  2. Uncheck this setting for pwsh.exe
Sign up to request clarification or add additional context in comments.

Comments

-2

Just posting my solution for the many enquiries of terminal launch failures with VSCode.

vscode (v1.79.2 but not limited to) will not open terminal window by default. OS Windows 10/11. Same version installed on my desktop device with Win 10 and it works every time? (Misleading as the following setting was already done)

Return code: The terminal process failed to launch: A native exception occurred during launch (Cannot create process, error code: 740).

Search of error code: 740 results in nothing usable.

Checking the 'Run as Admin' checkbox in the exe properties and shortcuts run with elevated rights but the checkboxs' are NOT persistant. A just once event. So that is not a solution. Opening properties each time on launch is not practical and annoying. Additionally a taskbar link which is the most likely, does not have properties access. So the 'Run as Admin' process needs to drill back to and through the startmenu; each and every launch.

So I studied this matter further believing there must be a solution as I have experienced this previously and corrected when VSCode (Code.exe) is updated. But of course I could not remember how it was fixed. Looking deeper I finally noted a setting in the Properties/Compatability Tab. It is unexpected to search & see a permissions control in a compatability dialog! Guess what? It was persistant.

So to enable the elevated access for persistancy requires a post install config to the code.exe path. Left click the VSCode icon on Start menu. Select 'File Location'. Left click 'Visual Studio Code' and browse to and select the properties dialog. Open the Compatiblity Tab. Look for the line 'run this program as an administrator' Check the box and the shortcuts will inherit the elevated level.

Notes: Win10 dialogs are somewhat different to Win11 but have the same functionality. (Surprise surprise 😊😊) : Future updates may not respect this settings. So you may need to repeat. : Many of the previous posts on editing 'settings.json' (????) have less relevance in this context. : Troubleshooting included removal of Win11 updates as a diagnostic. These were reinstalled and confirmed.

1 Comment

This just repeats (in an extremely long-winded way) the solution from the other answer posted two years prior: run VS Code as an administrator

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.