Skip to content

Instantly share code, notes, and snippets.

@kou1okada
Created January 13, 2016 02:10
Show Gist options
  • Save kou1okada/86267391d88adf1a90f4 to your computer and use it in GitHub Desktop.
Save kou1okada/86267391d88adf1a90f4 to your computer and use it in GitHub Desktop.
VCVARS Wrapper
@ECHO OFF
SET VER=C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC
SET ARCH=\bin\x86_amd64\vcvarsx86_amd64.bat
:OPTPARSE
IF "%1" == "" GOTO :MAIN
IF "%1" == "2003" GOTO :OPTPARSE7.1
IF "%1" == "2005" GOTO :OPTPARSE8
IF "%1" == "2008" GOTO :OPTPARSE9
IF "%1" == "2010" GOTO :OPTPARSE10
IF "%1" == "2012" GOTO :OPTPARSE11
IF "%1" == "2013" GOTO :OPTPARSE12
IF "%1" == "2015" GOTO :OPTPARSE14
IF "%1" == "5" GOTO :OPTPARSE5
IF "%1" == "6" GOTO :OPTPARSE6
IF "%1" == "7" GOTO :OPTPARSE7
IF "%1" == "7.1" GOTO :OPTPARSE7.1
IF "%1" == "8" GOTO :OPTPARSE8
IF "%1" == "9" GOTO :OPTPARSE9
IF "%1" == "10" GOTO :OPTPARSE10
IF "%1" == "11" GOTO :OPTPARSE11
IF "%1" == "12" GOTO :OPTPARSE12
IF "%1" == "14" GOTO :OPTPARSE14
IF /I "%1" == "VC5.0" GOTO :OPTPARSE5
IF /I "%1" == "VC6.0" GOTO :OPTPARSE6
IF /I "%1" == "VC7.0" GOTO :OPTPARSE7
IF /I "%1" == "VC7.1" GOTO :OPTPARSE7.1
IF /I "%1" == "VC8.0" GOTO :OPTPARSE8
IF /I "%1" == "VC9.0" GOTO :OPTPARSE9
IF /I "%1" == "VC10.0" GOTO :OPTPARSE10
IF /I "%1" == "VC11.0" GOTO :OPTPARSE11
IF /I "%1" == "VC12.0" GOTO :OPTPARSE12
IF /I "%1" == "VC14.0" GOTO :OPTPARSE14
IF "%1" == "1100" GOTO :OPTPARSE5
IF "%1" == "1200" GOTO :OPTPARSE6
IF "%1" == "1300" GOTO :OPTPARSE7
IF "%1" == "1310" GOTO :OPTPARSE7.1
IF "%1" == "1400" GOTO :OPTPARSE8
IF "%1" == "1500" GOTO :OPTPARSE9
IF "%1" == "1600" GOTO :OPTPARSE10
IF "%1" == "1700" GOTO :OPTPARSE11
IF "%1" == "1800" GOTO :OPTPARSE12
IF "%1" == "1900" GOTO :OPTPARSE14
IF "%1" == "32" GOTO :OPTPARSE32
IF "%1" == "64" GOTO :OPTPARSE64
IF /I "%1" == "x86" GOTO :OPTPARSE32
IF /I "%1" == "x86_64" GOTO :OPTPARSE64
IF /I "%1" == "amd64" GOTO :OPTPARSE64
IF NOT "%1" == "" GOTO :HELP
GOTO :NEXT
:OPTPARSE5
SET VER=C:\Program Files (x86)\Microsoft Visual Studio 5.0\VC
GOTO :NEXT
:OPTPARSE6
SET VER=C:\Program Files (x86)\Microsoft Visual Studio 6.0\VC
GOTO :NEXT
:OPTPARSE7
SET VER=C:\Program Files (x86)\Microsoft Visual Studio 7.0\VC
GOTO :NEXT
:OPTPARSE7.1
SET VER=C:\Program Files (x86)\Microsoft Visual Studio 7.1\VC
GOTO :NEXT
:OPTPARSE8
SET VER=C:\Program Files (x86)\Microsoft Visual Studio 8.0\VC
GOTO :NEXT
:OPTPARSE9
SET VER=C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC
GOTO :NEXT
:OPTPARSE10
SET VER=C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC
GOTO :NEXT
:OPTPARSE11
SET VER=C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC
GOTO :NEXT
:OPTPARSE12
SET VER=C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC
GOTO :NEXT
:OPTPARSE14
SET VER=C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC
GOTO :NEXT
:OPTPARSE32
SET ARCH=\bin\vcvars32.bat
GOTO :NEXT
:OPTPARSE64
SET ARCH=\bin\x86_amd64\vcvarsx86_amd64.bat
GOTO :NEXT
:NEXT
SHIFT
GOTO :OPTPARSE
:MAIN
ECHO %VER%%ARCH%
"%VER%%ARCH%"
GOTO :EOF
:HELP
ECHO Usage: %~n0 [ VER ^| ARCH ^| ... ]
ECHO VER is possible to take a 2013 or 2015.
ECHO ARCH is possible to take a 32 or 64.
ECHO Default values are 64 and 2015.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment