4

I'm trying to open Visual Studio Code from Powershell using the code command while inside a folder. When I try to do this, I always get this error:

Blockquote code : The term 'code' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. At line:1 char:1 + code . + ~~~~ + CategoryInfo : ObjectNotFound: (code:String) [], CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException

3
  • 2
    As the error message says: The command code is not recognized. The command needs to be in a directory in your Path environment variable. Commented Dec 3, 2019 at 17:08
  • Yeah even when i use the correct Path it wont open in VS code, even if i just want to open vs code (the program and not a project) i get this error Commented Dec 3, 2019 at 17:10
  • @Bill_Stewart I thought it was that problem too but I made some research and I found this closed issue: github.com/Microsoft/vscode/issues/22881. I think you (@Horbachus) can find your solution here. Commented Dec 3, 2019 at 17:12

2 Answers 2

4

I found a closed GitHub issue (https://github.com/Microsoft/vscode/issues/22881) with the exact same problem and the solution for the person who asked for a solution was:

Go to File > Preferences > Settings

Change the property "terminal.integrated.shell.windows" as follows:
      "terminal.integrated.shell.windows": "C:\Windows\System32\cmd.exe"

Restart visual studio.
Sign up to request clarification or add additional context in comments.

1 Comment

This tells VSCode to use the old Windows batch cmd, instead of PowerShell. I think you're supposed to put the path to the pwsh.exe there.
3

When you install Visual Studio Code, there is a checkbox in the installer labeled:

Add to PATH (requires shell restart)

installer image

Make sure this is checked, and that you restart any active shell instances after installation is completed.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.