25

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.

0

5 Answers 5

41

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

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

5 Comments

It is just opening vscode but then i have to click the button to open the current folder. It would of be great vscode would open the current folder automatically.
@Kuncevic you forgot to type the . if you type that it will open in the current folder of the cmd prompt.
I have installed VS code successfully, but when I run code . command sitting on the current project directory it give me error that : code is not recognized as internal or external command... how can I verify is it installed please ?
@sortednoun are you using git bash? You could try this if you are seangwright.me/blog/tools/….
It's better to launch "code.cmd" instead of just "code" (which launches code.exe). See stackoverflow.com/questions/56134836/…
8

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

1 Comment

You can make code . work by add the config to your powershell profile Set-Alias code 'C:\Users\YOU_USERNAME\AppData\Local\Programs\Microsoft VS Code Insiders\bin\code-insiders.cmd '
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!

Comments

1

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

3 Comments

... Did you just answer your own question as if you were someone else?
@ReticulatedSpline Yes. stackoverflow.com/help/self-answer. There was a blog post about it earlier last year I think and it said to ask the question as if you didn't know the answer. You can still answer if you can get it working in git bash I can't seem to figure that out right now.
@ReticulatedSpline: This is perfectly cromulent SO etiquette :)
0

Point your command prompt to the specific folder that has the file that you want to open. Let's say you want to open the file titled main.scss. Simply run this command:

start code main.scss

If Visual Studio Code is already open, you can simply do:

code main.scss

Comments

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.