Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Run .bat file on VS cmd prompt

I have created a compile.bat and run.bat files, but when I double click on them they run on the Windows cmd prompt instead of the VS cmd prompt.

This is what I have in my compile.bat file:

devenv FileMgr.sln /rebuild debug
pause

The Windows cmd says "'devenv is not recognized as an internal or external command, operable program or batch file."

like image 810
jbisa Avatar asked Feb 11 '12 05:02

jbisa


People also ask

What are the advantages of using a batch file as compared to the command prompt?

The advantages of using batch files are the ease of writing them, the ability to edit the files without compiling anything, their cross-compatibility across Windows NT Operating Systems and their inherent ability to manipulate file systems due to their basis on MS-DOS.


2 Answers

If I recall correctly, all the Visual Studio Command Prompt is is a batch script itself that initializes paths and environment variables. So if you simply call that batch script at the top of yours, you'll have all those settings for your script.

According to this question, MSVC 2008 has that batch file here:

call "C:\Program Files\Microsoft Visual Studio 2008\VC\vcvarsall.bat

It may not be in exactly the same place, but it should be something similar on your machine.

like image 179
Tyler Gill Avatar answered Sep 20 '22 19:09

Tyler Gill


you need devenv.exe to be present at location where your compile.bat is running. Please look at solution given here-

Simply type devenv.exe from the command line. If you get a message like this, then you do not have devenv.exe in your path. >>> 'devenv.exe' is not recognized as an internal or external command, operable program or batch file. >>> To fix this simply run the batch file, vsvars32.bat that comes with Visual Studio.NET from the command line in the working folder. After you run this batch file devenv.exe will be available from the command line in that folder.

http://windowsclient.net/blogs/faqs/archive/2006/05/26/how-do-i-start-visual-studio-from-the-command-line.aspx

I would usually copy the devenv.exe manually to the location where my bat file is kept.

like image 28
DotNetUser Avatar answered Sep 20 '22 19:09

DotNetUser