- Article
- 7 minutes to read
Applies to: Visual Studio
Visual Studio for Mac
Visual Studio Code
Visual Studio includes two command-line shells for developers, a command prompt and an instance of PowerShell, as follows:
Visual Studio Developer Command Prompt - A standard command prompt with certain environment variables set to make using command-line developer tools easier. Available since Visual Studio 2015.
Visual Studio Developer PowerShell - More powerful than a command prompt. For example, you can pass the output of one command (known as a cmdlet) to another cmdlet. This shell has the same environment variables set as Developer Command Prompt. Available since Visual Studio 2019.
Starting in Visual Studio 2019, Visual Studio includes an integrated terminal that can host either of these shells (Developer Command Prompt and Developer PowerShell). You can also open multiple tabs of each shell. The Visual Studio terminal is built on top of Windows Terminal. To open the terminal in Visual Studio, select View > Terminal.
Tip
This page describes how to use the command-line shells in Visual Studio. If you're looking for the equivalent in Visual Studio Code—also known as VS Code—see Command Line Interface (CLI) and Terminal Basics.
When you open one of the developer shells from Visual Studio, either as a separate app or in the Terminal window, it opens to the directory of your current solution (if you have a solution loaded). This behavior makes it convenient to run commands against the solution or its projects.
Both shells have specific environment variables set that enable you to use command-line developer tools more easily. After opening one of these shells, you can enter the commands for different utilities without having to know where they're located.
Popular commands | Description |
---|---|
MSBuild | Build a project or solution |
clrver | A .NET Framework tool for CLR |
ildasm | A .NET Framework tool for disassembler |
dotnet | A .NET CLI command |
dotnet run | A .NET CLI command |
CL | C/C++ compile tool |
NMAKE | C/C++ compile tool |
LIB | C/C++ build tool |
DUMPBIN | C/C++ build tool |
Start in Visual Studio
Follow these steps to open Developer Command Prompt or Developer PowerShell from within Visual Studio:
Open Visual Studio.
On the menu bar, select Tools > Command Line > Developer Command Prompt or Developer PowerShell.
Start from Windows menu
Another way to start the shells is from the Start menu. You may have multiple command prompts, depending on the version of Visual Studio and any additional SDKs and workloads you've installed.
Windows 11
Select Start
, and then in the Type here to search dialog box, enter either
developer command prompt
ordeveloper powershell
.Select the App result that's associated with your search text.
Windows 10
Select Start
, and then scroll to the letter V.
Expand the Visual Studio 2019 or Visual Studio 2022 folder.
If you're running Visual Studio 2019, select either Developer Command Prompt for VS 2019 or Developer PowerShell for VS 2019. If you're running Visual Studio 2022, select either Developer Command Prompt for VS 2022 or Developer PowerShell for VS 2022.
Alternatively, you can start typing the name of the shell in the search box on the taskbar, and select the result you want as the result list starts to display the search matches.
Windows 8.1
Go to the Start screen, by pressing the Windows logo key
on your keyboard for example.
On the Start screen, press Ctrl+Tab to open the Apps list, and then press V. This brings up a list that includes all installed Visual Studio command prompts.
If you're running Visual Studio 2019, select either Developer Command Prompt for VS 2019 or Developer PowerShell for VS 2019. If you're running Visual Studio 2022, select Developer Command Prompt for VS 2022 or Developer PowerShell for VS 2022.
Windows 7
Select Start and then expand All Programs.
Select Visual Studio 2019 > Visual Studio Tools > Developer Command Prompt for VS 2019 or Developer PowerShell for VS 2019. (If you're running Visual Studio 2022, look for the same items that include "2022" instead of "2019".)
If you have other SDKs installed, such as the Windows 10 SDK or previous versions, you may see additional command prompts. Check the documentation for the individual tools to determine which version of the command prompt you should use.
Start from file browser
Usually, the shortcuts for the shells you have installed are placed in the Start Menu folder for Visual Studio, such as in %ProgramData%\Microsoft\Windows\Start Menu\Programs\Visual Studio 2019\Visual Studio Tools. But if searching for the command prompt doesn't produce the expected results, you can try to manually locate the files on your machine.
Developer Command Prompt
Search for the name of the command prompt file, which is VsDevCmd.bat, or go to the Tools folder for Visual Studio, such as %ProgramFiles%\Microsoft Visual Studio\2022\Community\Common7\Tools (the path changes according to your Visual Studio version, edition, and installation location).
Once you've located the command prompt file, open it by entering the following command in a regular command prompt window:
"%ProgramFiles%\Microsoft Visual Studio\2022\Community\Common7\Tools\VsDevCmd.bat"
Or enter the following command in the Windows Run dialog box:
%comspec% /k "C:\Program Files\Microsoft Visual Studio\2022\Community\Common7\Tools\VsDevCmd.bat"
"%ProgramFiles(x86)%\Microsoft Visual Studio\2019\Community\Common7\Tools\VsDevCmd.bat"
Or enter the following command in the Windows Run dialog box:
%comspec% /k "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\Tools\VsDevCmd.bat"
Tip
Make sure to edit the path to match the version or edition of Visual Studio that you're using.
Developer PowerShell
Search for a PowerShell script file named Launch-VsDevShell.ps1, or go to the Tools folder for Visual Studio, such as %ProgramFiles(x86)%\Microsoft Visual Studio\2019\Community\Common7\Tools. (The path changes according to your Visual Studio version, edition, and installation location.) Once you've located the PowerShell file, run it by entering the following command at a Windows PowerShell or PowerShell 6 prompt:
& 'C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\Tools\Launch-VsDevShell.ps1'
By default, the Developer PowerShell that launches is configured for the Visual Studio installation whose install path the Launch-VsDevShell.ps1 file is located in.
Tip
The execution policy must be set in order for the cmdlet to run.
The Launch-VsDevShell.ps1
script works by locating the Microsoft.VisualStudio.DevShell.dll
PowerShell module in the Visual Studio installation path, loading it, and then invoking the Enter-VsDevShell
cmdlet. Installed shortcuts, like those in the Start menu, load the module and invoke the cmdlet directly. Launch-VsDevShell.ps1
is the recommended way to initialize Developer PowerShell interactively or for scripting build automation.
Command-line arguments
You can use command-line arguments for either of the shells, Developer Command Prompt or Developer PowerShell.
Target Architecture and Host Architecture
For build tools -- like the C++ compiler -- that create outputs targeting specific CPU architectures, the developer shells can be configured using the appropriate command-line argument. The architecture of the build tool binaries can also be configured by using command-line arguments. This is useful when the build machine is a different architecture than the target architecture.
Tip
Beginning with Visual Studio 2022, msbuild
will default to a 64-bit msbuild.exe binary, regardless of the Host Architecture.
Shell | Argument |
---|---|
Developer Command Prompt | -arch=<Target Architecture> |
Developer Command Prompt | -host_arch=<Host Architecture> |
Developer PowerShell | -Arch <Target Architecture> |
Developer PowerShell | -HostArch <Host Architecture> |
Important
Developer PowerShell arguments -Arch and -HostArch are only available beginning with Visual Studio 2022 version 17.1.
The following table lists which architectures are supported, and whether they can be used for Target Architecture or Host Architecture arguments.
Architecture | Target Architecture | Host Architecture |
---|---|---|
x86 | Default | Default |
amd64 | Yes | Yes |
arm | Yes | No |
arm64 | Yes | No |
Tip
If you set only Target Architecture, the shells attempt to make the Host Architecture match. This can result in errors when only the Target Architecture is set to a value that's not also supported by Host Architecture.
Examples
Start the Developer Command Prompt for Visual Studio 2019 Community Edition on a 64-bit machine, creating build outputs that target 64-bit:
"%ProgramFiles(x86)%\Microsoft Visual Studio\2019\Community\Common7\Tools\VsDevCmd.bat" -arch=amd64
Start the Developer Command Prompt for Visual Studio 2019 Community Edition on a 64-bit machine, creating build outputs that target arm:
"%ProgramFiles(x86)%\Microsoft Visual Studio\2019\Community\Common7\Tools\VsDevCmd.bat" -arch=arm -host_arch=amd64
Start the Developer PowerShell for the Community Edition of Visual Studio 2022 version 17.1 or later on a 64-bit machine, creating build outputs that target arm64:
& 'C:\Program Files (x86)\Microsoft Visual Studio\2022\Community\Common7\Tools\Launch-VsDevShell.ps1' -Arch arm64 -HostArch amd64
SkipAutomaticLocation
For Developer PowerShell, the starting directory of the shell is the Visual Studio Project Location. This default locale overrides any other paths, such as working directory. This behavior can be turned off by using the command-line argument -SkipAutomaticLocation
. This can be useful if you want the shell to stay in the current directory after initialization.
The Project Location can be adjusted in Tools > Options > Projects & Solutions > Project Location.
Tip
The command-line arguments -Arch
, -HostArch
, and -SkipAutomaticLocation
are supported by both the Launch-VsDevShell.ps1
script and the Enter-VsDevShell
cmdlet.
See also
- Windows Terminal
- .NET Framework Tools
- Use the Microsoft C++ toolset from the command line
FAQs
How do I use Visual Studio developer in command prompt? ›
Start in Visual Studio
Follow these steps to open Developer Command Prompt or Developer PowerShell from within Visual Studio: Open Visual Studio. On the menu bar, select Tools > Command Line > Developer Command Prompt or Developer PowerShell.
To build a specific target of a specific project in a solution. At the command line, type MSBuild.exe <SolutionName>. sln , where <SolutionName> corresponds to the file name of the solution that contains the target that you want to execute.
How do I get the shell command in Visual Studio code? ›To do this, press CMD + SHIFT + P, type shell command and select Install code command in path. Afterwards, navigate to any project from the terminal and type code . from the directory to launch the project using VS Code.
How to open cmd instead of PowerShell in Visual Studio Code? ›- Visual Studio Code Tips – Switch between Command Prompt vs Powershell in Visual Studio Code Terminal.
- Steps 1: Go to Terminal and Select Default Shell.
- Step 2: Select Command Prompt or Windows PowerShell.
- Depending on the version of Windows you're using, perform one of the following steps: In Windows 10, open the Start menu, and then scroll to Visual Studio. ...
- Next, right-click either Visual Studio 2019 or Visual Studio 2022, and then select More > Run as administrator.
The most notable advantage of using PowerShell over the command prompt is PowerShell's extensibility. Although you can create tools for both by writing scripts, the command prompt is limited as an interpreter.
How do I start Visual Studio code from command line Windows? ›Once your terminal is open, you can open VS Code from it by typing $ code . Then hit enter . Once you hit enter , VS Code will now open.
What is Visual Studio command line? ›The Command window is used to execute commands or aliases directly in the Visual Studio integrated development environment (IDE). You can execute both menu commands and commands that do not appear on any menu. To display the Command window, choose Other Windows from the View menu, and select Command Window.
How do I run a solution in command prompt? ›- Navigate to your solution folder.
- Run: msbuild myproject.sln /p:Configuration=Release (or Debug)
- cd myproject (within your solution folder - it's a sub-folder)
- cd bin.
- cd Release (or Debug)
- Run: myproject.exe.
- Open the terminal. Go to the directory where you want to create your script.
- Create a file with .sh extension.
- Write the script in the file using an editor.
- Make the script executable with command chmod +x <fileName>.
- Run the script using ./<fileName>.
How to install Visual Studio command-line tools? ›
Download and install the tools
If you only want the command-line toolset, download the Build Tools for Visual Studio. When you run the downloaded executable, it updates and runs the Visual Studio Installer. To install only the tools you need for C++ development, select the Desktop development with C++ workload.
- Create a new file called demo.sh using a text editor such as nano or vi in Linux: nano demo.sh.
- Add the following code: ...
- Set the script executable permission by running chmod command in Linux: chmod +x demo.sh.
- Execute a shell script in Linux: ./demo.sh.
Right-click on the taskbar at the bottom of the screen and select Taskbar settings with the gear icon. 2. The Taskbar settings window will open. Make sure the setting "Replace Command Prompt with Windows PowerShell in the menu when I right-click the start button or press Windows key + X" is toggled off.
How do I use CMD instead of PowerShell in Windows? ›The most straightforward method to change to CMD is by using keyboard shortcuts. Press Ctrl + Shift + 2 while the Terminal window is in focus. This opens a new tab with the Command Prompt shell. You can now close the first tab and start working using CMD.
How to use PowerShell in Visual Studio? ›- Open Visual Studio Code.
- File >> Preferences >> Extensions (Shortcut key: Ctrl+Shift+X). Search and select “PowerShell” in the Extensions pane.
- Click the “Install” button for the “PowerShell” extension, and then click the “Reload” button to enable the extension.
- Press the Windows Start button at the bottom left.
- Type in "Command Prompt".
- Right click on Command Prompt and click "Run as administrator".
- Click Yes if the Windows 10 User Account Control prompt is displayed.
- The Command Prompt should appear.
- Open Windows Terminal.
- Click the menu button next to the new tab and select the Settings option.
- Under the “Profiles” section, click on Command Prompt.
- Turn on the “Run this profile as Administrator” toggle switch to run Command Prompt elevated automatically.
To do so, open a run-box, write cmd , and press Control + Shift + Enter to open the command prompt as an administrator.
Is Windows command prompt and PowerShell the same? ›In Windows 10, the “traditional” command prompt that we've been using for years (dozens of years, to be exact) has been replaced by PowerShell. Of course, you can still call good old cmd.exe, but all menus and hotkeys now contain PowerShell as a default option, instead of CMD.
Should I use Windows Terminal or PowerShell? ›Windows Terminal Is All You Need
Windows Terminal allows you to run Bash and other command-line utilities, including PowerShell. It also supports more characters, has a fancy new text rendering engine, and allows you to customize its appearance.
Is Windows PowerShell a command-line? ›
The user interface of PowerShell is a command-line interface; that of Bash is a text command-line interface. PowerShell can be used on any version of Windows from Windows 97 onward.
What is the difference between command line and terminal? ›A command-line is any kind of interface that is used by entering (textual) commands. The terminal is one of these, but some programs have their own command-line interfaces.
How to install VS Code in Windows 10 step by step? ›- Step 1 : Download VS code from here Link.
- Step 2 : Download the Visual Studio Code installer for Windows. Once it is downloaded, run the installer (VSCodeUserSetup-{version}.exe). Then, run the file – it will only take a minute. Accept the agreement and click “next.”
Start Without Debugging – When you select this option (press Ctrl + F5 ) to run the application, Visual Studio will launch your application without loading the symbols or attaching the Debugger. With this option selected: Application won't pause if you have any breakpoint within the code.
What is the purpose of command prompt? ›What is the Command Prompt. In Windows operating systems, the Command Prompt is a program that emulates the input field in a text-based user interface screen with the Windows Graphical User Interface (GUI). It can be used to execute entered commands and perform advanced administrative functions.
What does Windows command-line use? ›Windows has two command-line shells: the Command shell and PowerShell. Each shell is a software program that provides direct communication between you and the operating system or application, providing an environment to automate IT operations.
How do I master a command prompt? ›- Type cmd in the Start menu search bar.
- Right-click the Best Match and click Open file location.
- Right-click the Command Prompt shortcut and click Properties.
- On the Shortcut tab, click Advanced.
- Check Run as administrator and click OK twice.
The quickest way to access the Run command window is to use this keyboard shortcut: Windows + R. Simply hold down the Windows key and press R on your keyboard. On top of being very easy to remember, this method works in all versions of Windows, from the dated Windows 7 to the newer Windows 10 and the latest Windows 11.
Can I do shell scripting in Windows? ›You can use the Windows Subsystem for Linux (WSL) to run shell script files on Windows because WSL allows you to run a Linux environment on your Windows machine. This environment includes most command-line tools and applications that are typically used on Linux, including the ability to run shell scripts.
How do I run a shell script in Visual Studio? ›In this case it's simple : add your . sh script file to your Visual Studio solution one way or another, then right-click on it in the Solution Explorer, and select « Open With… ». This will determine what program gets called when you double click on the file in this view.
How do I enable shell in Windows? ›
To turn on Shell Launcher in Windows features
Go to Control Panel > Programs and features > Turn Windows features on or off. Expand Device Lockdown. Select Shell Launcher and OK.
They allow programmers to compile programs and debug them, convert files, and perform a number of tasks for handling the resources required for making applications and other tools.
How to run Visual Basic command line? ›From the Start menu, click on the Accessories folder, and then open the Windows Command Prompt. At the command line, type vbc.exe sourceFileName and then press ENTER.
How do I download command line tools for Windows? ›- On the developer portal, open the "DOWNLOAD" panel.
- Download the command line tool ZIP file.
- Extract the downloaded ZIP file and open the directory in your terminal. ...
- Install the modules required to run the tool.
A shell command is one that is processed internally by the shell. There is no corresponding executable program. Take cd for instance. There is no /bin/cd program, say, and which cd specifies that it is a built-in command.
What is shell script command line? ›What are Command-Line Arguments? Command-line arguments are parameters that are passed to a script while executing them in the bash shell. They are also known as positional parameters in Linux. We use command-line arguments to denote the position in memory where the command and it's associated parameters are stored.
What is shell scripting used for? ›Using a shell script is most useful for repetitive tasks that may be time consuming to execute by typing one line at a time. A few examples of applications shell scripts can be used for include: Automating the code compiling process. Running a program or creating a program environment.
How do I use Command Prompt in PowerShell? ›The command to open Command Prompt from Windows PowerShell is exactly the same as the command to open Command Prompt from Command Prompt. In Windows PowerShell, just type start cmd.exe and press Enter.
Should I replace CMD with PowerShell? ›For systems administrators and other IT functions, PowerShell is the way to go. There isn't any command left in CMD that isn't in PowerShell, and PowerShell includes cmdlets for any administration function you could need.
How to run PowerShell as admin in CMD script? ›How do you run PowerShell as an administrator from a command line? To run PowerShell as administrator from cmd, Open the command prompt, type PowerShell, and then enter “Start-Process powershell -Verb RunAs”. This will open a new PowerShell window with administrator privileges.
How to format PowerShell in Visual Studio? ›
Available in PowerShell Tools for Visual Studio 2022.2. 0 or later. Requires a PowerShell Pro Tools license. Code formatting can be accomplished by using the standard Ctrl+K , Ctrl+D keyboard shortcut within Visual Studio.
How do I enable Windows Powershell scripts? ›- Open PowerShell as administrator.
- In the PowerShell window, type the following command and press Enter: Set-ExecutionPolicy RemoteSigned.
- If prompted, press A to confirm the action.
...
How to Enable Developer Mode in Windows 10
- Open Settings.
- Go to Update and Security -> For developers.
- Enable the option called "Developer mode". Click Yes in the confirmation dialog:
Type "start [filename.exe]" into Command Prompt, replacing "filename" with the name of your selected file. Replace "[filename.exe]" with your program's name. This allows you to run your program from the file path.
How do I change the directory in developer command prompt? ›- Type cd followed by a space in the command prompt window.
- Drag and drop the folder you want to browse into the window.
- Press Enter.
Start Without Debugging – When you select this option (press Ctrl + F5 ) to run the application, Visual Studio will launch your application without loading the symbols or attaching the Debugger. With this option selected: Application won't pause if you have any breakpoint within the code.
How to enable developer mode in Windows 10 using CMD? ›Click the Windows icon and the Settings icon, and select Update & Security. Select For developers and turn on the switch under Developer Mode (or select Developer Mode in certain system versions). In the displayed dialog box, select Yes.
How do I access developer tools in Windows? ›To open the developer console in Google Chrome, open the Chrome Menu in the upper-right-hand corner of the browser window and select More Tools > Developer Tools. You can also use Option + ⌘ + J (on macOS), or Shift + CTRL + J (on Windows/Linux).
How do I enable developer mode? ›- On your device, find the Build number option. The following table shows the settings location of the Build number on various devices: ...
- Tap the Build Number option seven times until you see the message You are now a developer! ...
- Return to the previous screen to find Developer options at the bottom.
Once your terminal is open, you can open VS Code from it by typing $ code . Then hit enter . Once you hit enter , VS Code will now open.
What is the Run command in Windows Command Prompt? ›
The Run command on an operating system such as Microsoft Windows and Unix-like systems is used to directly open an application or document whose path is known.
How do I open VS Code directly from Command Prompt? ›To get an overview of the VS Code command-line interface, open a terminal or command prompt and type code --help . You will see the version, usage example, and list of command line options.
How do I change the Command Prompt directory in VS code? ›Open Visual Studio Code and access the Command Palette (⇧⌘P) and start typing shell command and select option Shell Command: Install 'code' command in PATH. After that you're able to start a new terminal window, change into your project directory and use code . to open the current directory in Visual Studio Code.
How do I show all files in Command Prompt? ›Navigate to the directory containing the folders you wish to appear in your list. Click in the address bar and replace the file path by typing cmd then press Enter. This should open a black and white command prompt displaying the above file path. Type dir /A:D.
How do I change the root directory in Windows Command Prompt? ›Open Command Prompt in Windows 10
In the power user task menu, select Command Prompt (Admin) (Figure 8). This will open the Command Prompt window (Figure 9). To change to the Root directory type cd\ and press Enter (Figure 10). NOTE: The Root directory is the best place to enter any required commands or instructions.
Press the Win + R on your keyboard. In the Run dialog box, type “cmd” into the field and then press Ctrl + Shift + Enter. This will open Command Prompt with administrative privileges. From here, you can enter any commands that you need to run.
How do I run a command in Visual Studio? ›The Command window is used to execute commands or aliases directly in the Visual Studio integrated development environment (IDE). You can execute both menu commands and commands that do not appear on any menu. To display the Command window, choose Other Windows from the View menu, and select Command Window.
How do I start diagnostic tools without debugging? ›Collect profiling data without debugging
Select Debug > Performance Profiler, or press Alt+F2. On the diagnostic tools launch page, select one or more tools to run. Only the tools that are applicable to the project type, operating system, and programming language are shown.