spb
spb

Reputation: 4239

" 'devenv' is not recognized as an internal or external command ..."

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

Upvotes: 16

Views: 49458

Answers (7)

gil123
gil123

Reputation: 679

Nothing work for me except just deleting the folder C:\Users\<username>\AppData\Local\Microsoft\VisualStudio But this will fully remove all settings so be aware about it

Upvotes: 0

Avius
Avius

Reputation: 470

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 2022\Common7\IDE\"

EDIT: Updated path to Visual Studio 2022

Upvotes: 39

VivekDev
VivekDev

Reputation: 25419

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.

Upvotes: 0

KalenGi
KalenGi

Reputation: 2077

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

Upvotes: 1

Shadi Alnamrouti
Shadi Alnamrouti

Reputation: 13258

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.

Upvotes: 1

Manohar Reddy Poreddy
Manohar Reddy Poreddy

Reputation: 27395

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

Upvotes: 5

Jim Beveridge
Jim Beveridge

Reputation: 340

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.

Upvotes: 4

Related Questions