Starting Visual Studio from a command prompt

Viewed 134788

I have three different versions of Visual Studio installed on my machine, Visual Studio 2003, Visual Studio 2008, and VS2005.

How do I start a particular version of Visual Studio using a command prompt?

devenv.exe opens the latest version of Visual Studio. What should I do if I want to open Visual Studio 2003 using a command prompt?

17 Answers

Haven't tested on preceding versions - but to launch Visual Studio 2019 you can just enter start devenv to launch right away without entering into a path

You have to use the path to distinguish them. For instance, here is the Visual Studio 2005 command on my laptop:

    "C:\Program Files\Microsoft Visual Studio 8\Common7\IDE\devenv.exe"

Here's another tip: You can figure out how to run various Windows applications from the command line by finding them in the Windows Start Menu, right-clicking on the icon, select properties, and then on the Shortcut tab, look at the Target textbox. Copy that text out and usually you can use it at a console command line.

Use devenv.exe for the specific version of Visual Studio. There will be one located in the Common7\IDE folder of the install. Here are the directories as I remember for the various versions.

  • 2008:

    %ProgramFiles%\Microsoft Visual Studio 9.0\Common7\Ide\devenv.exe
    
  • 2005:

    %ProgramFiles%\Microsoft visual Studio 8\Common7\Ide\devenv.exe
    

For Visual Studio on a mac, you can:

open '/Applications/Visual Studio.app' [path_to].sln

I create an alias in my bash_profile so I can just navigate to a directory and open it in VS:

echo "alias vs=\"open '/Applications/Visual Studio.app' *.sln\"" >> ~/.bash_profile

You can also use the "Visual Studio 2005 Command Prompt" and "Visual Studio 2008 Command Prompt" to load a version-specific command shell environment, and then run devenv. This is typically found under Start -> Programs -> Visual Studio -> Visual Studio Tools

If you can't or don't want to access it via the Start menu, you can also "load" the VS-version specific environment in a normal command shell using the following (for VS 2008, with a default install path): (note: change x86 as appropriate for your platform)

(32 bit) %comspec% /k ""C:\Program Files\Microsoft Visual Studio 8\VC\vcvarsall.bat"" x86

(64 bit) %comspec% /k ""C:\Program Files (x86)\Microsoft Visual Studio 8\VC\vcvarsall.bat"" x86

or for VS 2008 (with default install path):

(32 bit) %comspec% /k ""C:\Program Files\Microsoft Visual Studio 9.0\VC\vcvarsall.bat"" x86

(64 bit) %comspec% /k ""C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\vcvarsall.bat"" x86

Each sets the environment so if you then subsequently execute devenv it'll load the correct version.

  • Put C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\Common7\IDE\ in the path of your computer.
  • Then open a new command prompt.
  • Change the directory to your project folder.
  • Type devenv to open the project in Visual Studio from the command prompt. This opens the project up in folder view. It has to have a .sln file to do the next part.
  • Click the switch views drop-down arrow and choose the .sln file.

The solution explorer will now display the solution.

Use an abolute path, for example, C:\Program Files (x86)\Microsoft Visual Studio 9.0\Common7\IDE\devenv.exe.

1) devenv (to open VS)

2) devenv *.sln (then tab to autocomplete and enter to open VS and auto-load current solution)

By default, this only works in Developer Command Prompt. To make it work in a normal console (I use cmder) you need to add folder path to devenv.exe to the System environment variable name Path. For me that is this one:

C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Common7\IDE

You can also use this script and save it as vs.bat and then it will find for you *.sln file in the folder and automatically open visual studio with solution loaded (as in 2.)

use this command:

C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\IDE\devenv.exe

You can create a bat script for any visual studio version. You can find my script below.

start /B "" "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\Common7\IDE\devenv.exe"

Even, you can create an alias following this post

Go to your project directory in cmd. (ex. cd <=FOLDER_PATH=>)

type code and press enter.

Related