How to Open Visual Studio Code Using PowerShell
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.
Using Code Command
You can type
code either in PowerShell or Command Prompt in order to open Visual Studio Code.
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'
Start-Process command will launch VS Code immediately.
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 (&)
& 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'
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
Invoke-Item or Call Operator
& to open VS Code.