10

My question is, how can I make the VS Code command line work properly when manually adding it to PATH on Windows?

Inside of Visual Studio Code, I first tried to install it with the tickbox "install to PATH", but when I typed code in the command prompt, it said command not recognized. So I manually edited PATH and added C:\Program Files (x86)\Microsoft VS Code.

However, when running commands such as:

code -v 

the command prompt doesn't print anything, but launches Visual Studio Code instead.

2
  • If VSCode is starting, you've properly added it to the PATH (otherwise, you'd get an error message about it not being a valid command). So your question is really why VSCode isn't recognizing the command-line options; you should edit to ask that instead. The title (and text about the PATH) are irrelevant. Commented Mar 1, 2017 at 21:55
  • If cmd is open then your path gets updated, you may need to restart cmd to get the updated variables. Commented Mar 1, 2017 at 22:08

1 Answer 1

19

Your path environment variable should include C:\Program Files (x86)\Microsoft VS Code\bin instead of C:\Program Files (x86)\Microsoft VS Code (notice the added \bin at the end).

The bin sub directory provides the batch file code.cmd, that processes the command line before launching code.exe from the parent directory. Going through the batch file is required for the command line to work properly.

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

2 Comments

Thanks, my path was "C:\Program Files (x86)\Microsoft VS Code", it should have been "C:\Program Files (x86)\Microsoft VS Code\bin"
With the most recent updates of VS code, I needed to amend it to: C:\Users\{username}\AppData\Local\Programs\Microsoft VS Code_\bin

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.