Opening Microsoft Visual Studio Code from command prompt Windows

22,265

Solution 1

Navigate to the directory that you want to open and type code . to launch VS Code.

Solution 2

As many folks already suggested ways to open code from command prompt using code . command. This will only open Visual Studio Code Stable build. But If you have downloaded Visual Studio Code Insider build/version (Which has all latest build/features but unstable version) then you need to follow below instructions in windows :

  • Go to Control Panel\System and Security\System. Click on Advanced System Settings enter image description here
  • Click on Environment Variables enter image description here
  • Under System Variables tab, Click on Edit for Path Variable enter image description here
  • Add a new path C:\Users\tsabu\AppData\Local\Programs\Microsoft VS Code Insiders\bin (or) C:\Program Files\Microsoft VS Code Insiders\bin based on location at which you have installed vscode insider in your machine. enter image description here

    Open a new command prompt and type code-insiders . to open vscode-insider build/version

Solution 3

Short answer:

code your_path your_filename

Long answer:

Here your_path can simply be . if you want to use the current directory as your working path. Or .. for 1 level up, etc.

code is the name of the executable of Visual Studio Code (code.exe). If it doesn't launch, perhaps your VSC path hasn't been added to the path environment variable. Run this command to add it:

set PATH=";C:\Program Files\Microsoft VS Code\bin"

Of course you'll need to specify a different path if your VSC is installed somewhere else.

How can you find out the installation path? (click for screenshot) Go to "Start" menu, type in "Visual Studio Code", right click on the found program, "Properties", check "Target". Now you'll see!

Solution 4

It may come already added to your path when installed. Try using code <filename> in your command line. If it's not you can add the command line script's directory to your path. The command line script's directory is downloaded by default in the following location

C:\Users\<username>\AppData\Local\Code\bin
Share:
22,265
John
Author by

John

I'm a cofounder of a startup where I work as a full-stack Web Developer doing HTML/CSS, JavaScript, Node.js, and MongoDB. Some newer projects I'm working on are using the GRANDstack with Node.js. I really enjoy working with new flavors of JavaScript like ES6. I have a B.S. in Computer Science from Utah State University (USU). My favorite class I had at University was probably Discrete Mathematics which includes some of each of the following: set theory, logic, graph theory, combinatorics, and number theory. I also enjoyed USU's Computational Geometry and Advanced Algorithms course.

Updated on July 18, 2020

Comments

  • John
    John over 3 years

    Is there a way to launch Microsoft Visual Studio Code from the command line in windows? I can't even seem to find the directory for code on my computer. It didn't even ask me where to download it.