How to Open Visual Studio Code Using PowerShell
Introduction
Having the ability to open Visual Studio Code (VS Code) from PowerShell is extremely useful. It can save you time and energy by allowing you to quickly write the code without having to open the IDE manually.
In this article, we will walk you through how to open visual studio code using PowerShell.
Solution
Using Code Command
You can type code
either in PowerShell or Command Prompt in order to open Visual Studio Code.
code
Using Start-Process
Once you are in PowerShell environment, you can type in Start-Process
followed by the path of your VS Code executable file.
In this case, we are going to open VS Code where the executable file is physically located at C:\Users\HSURYOAT\AppData\Local\Programs\Microsoft VS Code\Code.exe
. You would type following script into PowerShell.
Start-Process 'C:\Users\HSURYOAT\AppData\Local\Programs\Microsoft VS Code\Code.exe'
The Start-Process
command will launch VS Code immediately.
Using Invoke-Item
Another useful command is Invoke-Item
which can also be used to open specific item from within PowerShell. To use this command, simply enter it followed by the path of VS Code executable file.
Invoke-Item 'C:\Users\HSURYOAT\AppData\Local\Programs\Microsoft VS Code\Code.exe'
This will automatically launch VS Code.
Using Call Operator (&)
Call Operator &
can also be used to open VS Code. The pattern is the same with previous example where the operator must be followed by the path to the executable file.
& 'C:\Users\HSURYOAT\AppData\Local\Programs\Microsoft VS Code\Code.exe'
Conclusion
Using Windows PowerShell commands makes opening VS Code incredibly easy and efficient, just remember we can just type code
in PowerShell. We can also use PowerShell cmdlet like Start-Process
, Invoke-Item
or Call Operator &
to open VS Code.