2

I am using Windows 7 and I want to set up an environment variable and use it in the same command.
Specifically, I want to execute the following 2 commands simultaneously as a single command-:

set MYPATH="C:\Program Files (x86)\Microsoft Visual Studio 11.0"
%MYPATH%\VC\vcvarsall.bat  

In other words, I want the Windows version of this.
This is what I've tried so far -:

set MYPATH="C:\Program Files (x86)\Microsoft Visual Studio 11.0" && cmd.exe /C "%MYPATH%\VC\vcvarsall.bat"

But it isn't working.
So, Is there any way of doing this in Windows ?

Community
  • 1
  • 1
Anmol Singh Jaggi
  • 8,376
  • 4
  • 36
  • 77
  • 1
    `cmd /c "C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\vcvarsall.bat"` <--- this does the same thing. If it isn't what you want to do then improve your question with actual details. – foxidrive Jun 10 '14 at 02:11
  • @foxidrive Thanks! I tried something like that previously, but it didn't work. So I googled and read somewhere that the only option to do this was to set the path as an environment variable and then call it. The spaces in the path caused a lot of problems! – Anmol Singh Jaggi Jun 10 '14 at 07:48

1 Answers1

2

This can be done by writing -:

cmd.exe /X /V:ON /C "set MYPATH="C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\varsall.bat" && !MYPATH!"  

Source

Community
  • 1
  • 1
Anmol Singh Jaggi
  • 8,376
  • 4
  • 36
  • 77
  • Although I still cannot understand why this is not working - `cmd.exe /X /V:ON /C "set MYPATH="C:\Program Files (x86)\Microsoft Visual Studio 11.0" && !MYPATH!\VC\varsall.bat"` – Anmol Singh Jaggi Jun 09 '14 at 23:19