14

Is there a way to just open a VS project from the command prompt? For example, the way with Atom, you can navigate to the folder you'd like to open and just run "atom ." Does that kind of utility exist for VS?

edit: Would the equivalent to this be "C:\> devenv /run SomeSolution.sln" ?

if so, great! But there still seems to be a problem because I think the "devenv" command should at least be recognized, but I currently get

'devenv' is not recognized as an internal or external command, operable program or batch file.

I saw that a S/O contributer recommended adding

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

to the PATH environment variables values like this, per MSDN, which I did, but I get the same message.

Can anyone explain what might be going on and how to fix it? Thanks

Community
  • 1
  • 1
spb
  • 4,049
  • 6
  • 22
  • 30
  • Use the Start menu to launch the Visual Studio command prompt (whatever version of VS you're using), in some versions called the Developer Command Window. From that prompt, `devenv` should work. You can't add an executable to the PATH; you can add the folder that executable is located, though. Nothing in the question (including answers or comments) recommending adding what you said to the PATH, however. – Ken White Jun 01 '16 at 22:18

6 Answers6

33

You need to add new path to existing Path value.

Complete solution:

  1. Go to MyComputer >> Properties >> Change Settings >> Advanced >> Environmental variables

  2. Click on Path value on bottom pane, and then click Edit.

  3. Add new path to your devenv.exe folder location. For me this is "D:\Program Files\Microsoft Visual Studio Community 2017\Common7\IDE\"

Avius
  • 410
  • 4
  • 9
5

On similar issue, for VS 2017, I wanted to build a solution, below worked fine:

call "C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\devenv.exe" Project.sln /build
Manohar Reddy Poreddy
  • 25,399
  • 9
  • 157
  • 140
4

This is much easier than it looks. Go to the root directory for the project, type the name of the .sln file, and hit Enter. Windows knows how to use the registry o find devenv.exe based on the extension of the file you run.

For example:

cd \Projects\SampleApp
SampleApp.sln

This technique is the same as if you opened the sln file by double clicking it in Explorer.

Jim Beveridge
  • 330
  • 2
  • 10
1

VS 2019 Community

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

Any Visual Studio Version

To find your specific devenv.exe path regardless of VS copy/version you can use cmd and then run:

cd \

dir /s divenv.exe

Note: The command dir /s may take a few minutes to find it.

Shadi Alnamrouti
  • 11,796
  • 4
  • 56
  • 54
1

Since I had no desire to update my PATH variable, I used the following steps to run devenv on the command prompt:

  1. Navigate to the Visual Studio shortcut on the Start menu
  2. Right-click the shortcut
  3. Click on properties
  4. Copy the path displayed in Target. This is the path to whatever version of devenv that you use.
  5. Paste the copied path into the command prompt and press enter
KalenGi
  • 1,766
  • 4
  • 25
  • 40
0

Mine is a windows machine, and for this command to work, devenv must be added to the path environment variable.

First ensure you have visual studio is installed on your machine.

On my machine, the devenv exe is available at the following location.

C:\Program Files\Microsoft Visual Studio\2022\Professional\Common7\IDE

Next add this to the path environment variable.

Open System Properties

Windws System Properties

Path Env Variable

Do not forget to close your command prompt and then start it again. This will enable the env vars to load into the command prompt.

VivekDev
  • 20,868
  • 27
  • 132
  • 202