-if "%VS140COMNTOOLS%" == "" (
- echo Could not find MS Visual Studio: variable VS140COMNTOOLS is not defined!
- exit 1
-) else if exist "%VS140COMNTOOLS%\..\IDE\devenv.exe" (
- set MSVC_EXE="%VS140COMNTOOLS%\..\IDE\devenv.exe"
-) else if exist "%VS140COMNTOOLS%\..\IDE\VCExpress.exe" (
- set MSVC_EXE="%VS140COMNTOOLS%\..\IDE\VCExpress.exe"
+@SET VC_VERSION_SHORT=15
+for /f "tokens=1,2*" %%a in ('reg query "HKLM\SOFTWARE\Wow6432Node\Microsoft\VisualStudio\SxS\VS7" /v "%VC_VERSION_SHORT%.0" 2^>nul') do set "VSPATH=%%c"
+IF NOT EXIST "%VSPATH%\VC\Auxiliary\Build\vcvarsall.bat" GOTO ERROR1
+
+if exist "%VSPATH%\Common7\IDE\devenv.exe" (
+ SET msvc_exe=devenv
+) else if exist "%VSPATH%\Common7\IDE\VCExpress.exe" (
+ SET msvc_exe=VCExpress