Using Visual Studio Command Prompt Tools Everywher

2019-07-04 20:46发布

How can I use the tools included in the VS command prompt (Programs | MS Visual Studio 2008 | Visual Studio Tools | Visual Studio 2008 Command Prompt) from any command prompt (ie without calling vcvarsall.bat) or program?

4条回答
迷人小祖宗
2楼-- · 2019-07-04 21:36

You might be interested in adding a "Visual Studio Command Prompt Here" context menu option in Windows Explorer. Scott Hanselman has a link to an .inf file you can run to make the registry changes for this

查看更多
Rolldiameter
3楼-- · 2019-07-04 21:40

To get it to work from a program, the easiest route is probably to set all the environment variables permanently for the user.

To use it from a command prompt... I just use the Command Prompt Tools shortcut as my normal command prompt shortcut, so I've always got them anyway. The good thing about this approach is that you can have different shortcuts for different versions - so I have a VS2008 shortcut and a VS2010 shortcut.

查看更多
乱世女痞
4楼-- · 2019-07-04 21:41

Perhaps add to your path var the locations of bin folders for the tools provided by visual studio

查看更多
老娘就宠你
5楼-- · 2019-07-04 21:47

The easiest way to do this is to add the PATH, INCLUDE, LIB and LIBPATH environment variables that are listed in the vsvarsXX.bat file for VS2005 on a 32 bit Intel box.

Here's the sample for vsvars32.bat:

@SET VSINSTALLDIR=C:\Program Files\Microsoft Visual Studio 8
@SET VCINSTALLDIR=C:\Program Files\Microsoft Visual Studio 8\VC
@SET FrameworkDir=C:\WINDOWS\Microsoft.NET\Framework
@SET FrameworkVersion=v2.0.50727
@SET FrameworkSDKDir=C:\Program Files\Microsoft Visual Studio 8\SDK\v2.0
@if "%VSINSTALLDIR%"=="" goto error_no_VSINSTALLDIR
@if "%VCINSTALLDIR%"=="" goto error_no_VCINSTALLDIR

@echo Setting environment for using Microsoft Visual Studio 2005 x86 tools.

@rem
@rem Root of Visual Studio IDE installed files.
@rem
@set DevEnvDir=C:\Program Files\Microsoft Visual Studio 8\Common7\IDE

@set PATH=C:\Program Files\Microsoft Visual Studio 8\Common7\IDE;C:\Program Files\Microsoft Visual Studio 8\VC\BIN;C:\Program Files\Microsoft Visual Studio 8\Common7\Tools;C:\Program Files\Microsoft Visual Studio 8\Common7\Tools\bin;C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\bin;C:\Program Files\Microsoft Visual Studio 8\SDK\v2.0\bin;C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727;C:\Program Files\Microsoft Visual Studio 8\VC\VCPackages;%PATH%
@set INCLUDE=C:\Program Files\Microsoft Visual Studio 8\VC\ATLMFC\INCLUDE;C:\Program Files\Microsoft Visual Studio 8\VC\INCLUDE;C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\include;C:\Program Files\Microsoft Visual Studio 8\SDK\v2.0\include;%INCLUDE%
@set LIB=C:\Program Files\Microsoft Visual Studio 8\VC\ATLMFC\LIB;C:\Program Files\Microsoft Visual Studio 8\VC\LIB;C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\lib;C:\Program Files\Microsoft Visual Studio 8\SDK\v2.0\lib;%LIB%
@set LIBPATH=C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727;C:\Program Files\Microsoft Visual Studio 8\VC\ATLMFC\LIB

@goto end

:error_no_VSINSTALLDIR
@echo ERROR: VSINSTALLDIR variable is not set. 
@goto end

:error_no_VCINSTALLDIR
@echo ERROR: VCINSTALLDIR variable is not set. 
@goto end

:end

Pick and fill in the values from there.

查看更多
登录 后发表回答