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 ?

2
  • 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. Commented Jun 10, 2014 at 2: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! Commented Jun 10, 2014 at 7:48

1 Answer 1

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

Sign up to request clarification or add additional context in comments.

1 Comment

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"

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.