Adding Visual Studio Code (VS Code) to Windows system Path manually is generally not required, because after installing this code editor, the system automatically adds that. It is necessary to have the Visual Studio code executable in the Path because only after that Windows recognize it and allow users to run VS Code commands from the command prompt or PowerShell without needing to navigate to the installation directory.
However, in case, for some reason if your Windows has not added the VS Code in the system Path then here is the tutorial to that manually.
1. Locating Visual Studio Code Installation Path:
To run the Visual Studio Code executables directly using the command prompt or PowerShell, first we need to find out where they are located after completing the VScode installation.
Generally, when we install an application in Windows, it saves all the files under C:\Program Files or C:\Program Files x86 directory. However, this is not the case with Microsoft VS Code. It resides under the App data folder of the current user. Follow the below steps to find the directory.
- Open File Explorer and navigate to C: Drive then open the Users folder after that current system user directory then go for AppData\Local\Programs\Microsoft VS Code\bin.
- For example in our case the username is H2S, so the default installation path is –
C:\Users\H2S\AppData\Local\Programs\Microsoft VS Code\bin.
- Copy the full path to the clipboard.
2. Accessing System Properties:
Once you have the path where the VScode is installed, right-click on the Windows Start button and select “System.”
After that in the System window under Device Specifiation you will find Related links, click on “Advanced system settings” given on the right side.
Now, in the System Properties window at bottom side click on the “Environment Variables…” button.
3. Editing User Environment Variables:
- In the Environment Variables window, under the “User Variables” section, find and select the “Path” variable.
- Click on the “Edit…” button to add a new path.
4. Adding VS Code to Path:
- Here on the “Edit Environment Variable” window, you will find a “New” button, click that to add a custom path.
- Paste the path to the Visual Studio Code installation directory that we have located and copied in Step 1 of this tutorial.
- Once done, click on the “OK” button to close each of the open windows and save the changes you have made.
5. Verifying the Path Addition:
We are done with all the necessary steps required to add the path of VS code or any other application. Now, let’s confirm whether it is working correctly, for that we can use the command line.
Close any already opened Command Prompt or PowerShell window and open any of them again. After that, type the given command and press the Enter key.
You will see the current version of VS code installed on your Windows. This also confirms that we can now use the “Code” command on CMD from any directory.
Note: If you had Visual Studio Code or any open command prompts before adding it to the Path, you may need to restart those applications for the changes to take effect.
Adding Visual Studio Code to the system Path in Windows will allow users to conveniently open the code editor and perform other tasks using Terminal or PowerShell. We have tried to list the steps of doing that as simple as possible. So, whether you’re launching VS Code, accessing extensions, or executing specific commands, having it in the system Path streamlines your workflow. If you are facing any difficulty in performing this tutorial, the comment section is all yours, do let’s know…