简体   繁体   中英

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."

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.

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.

The VS cmd prompt sets some additional environment variables and adds data to existing (eg the PATH variable). You might consider adding the path of devenv to you normal path.

You may specify full path of devenv.exe:

C:\\Program Files (x86)\\Microsoft Visual Studio 8\\Common7\\IDE\\devenv.exe FileMgr.sln /rebuild debug

But your batch file won't be portable to other machines/IDEs.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM