4

Thanks for reading this thread.

Basically I am wondering how I can use relative path/environment variable pointing to visual studio 2012 vcvarsall.bat file in a script?

I am currently using absolute path:

call "C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\vcvarsall.bat" x86_amd64

How can I do something like this?

call "$(System)\$(Program Files)$(VS)\$(VC)\vcvarsall.bat" x86_amd64

Thanks a lot.

EDIT

What if I have more than one version of visual studio? I have vs2008 and vs2012 both installed on my computer.

Ono
  • 1,357
  • 3
  • 16
  • 38

1 Answers1

5

Using a Visual Studio macro VCInstallDir

call $(VCInstallDir)vcvarsall.bat

Or without Visual Studio macros use VS110COMNTOOLS

call $(VS110COMNTOOLS)..\..\VC\vcvarsall.bat
David Ruhmann
  • 11,064
  • 4
  • 37
  • 47
  • What if I have more than one version of visual studio? I have vs2008 and vs 2012. – Ono Mar 13 '14 at 14:21
  • Also the second one is not working. No response when it is executing. – Ono Mar 13 '14 at 14:39
  • @Ono $(VCInstallDir) will flex based upon the Platform Toolset selected for the project meaning that it handles multiple installs of Visual Studio. – David Ruhmann Mar 13 '14 at 14:46
  • @Ono What response are you expecting? Please provide details on how you are executing these statements. Both commands work for me. – David Ruhmann Mar 13 '14 at 14:52
  • I got the second one: call "%VS110COMNTOOLS%\..\..\vc\vcvarsall.bat" – Ono Mar 13 '14 at 15:06
  • I am still not sure about the first one. I have windows 7, vs2008 and vs2012; so if I do call $(VCInstallDir)vcvarsall.bat, which vcvarsall.bat is going to be invoked, the vs2008 or the vs2012? – Ono Mar 13 '14 at 15:08
  • @Ono For VCInstallDir, if the project is using the vc90 toolset, the VS2008 vcvarsall.bat will be called. If the project is using the vc110 toolset, the VS2012 vcvarsall.bat will be called. Project > Properties > General > Platform Toolset. If the command is not run in relation to a project (Visual Studio Command Prompt), the visual studio that it is run against will be used. – David Ruhmann Mar 13 '14 at 15:27
  • I see. Really appreciate it! – Ono Mar 13 '14 at 15:32