1set /a errorno=1 2for /F "delims=#" %%E in ('"prompt #$E# & for %%E in (1) do rem"') do set "esc=%%E" 3 4rem https://github.com/Microsoft/vswhere 5rem https://github.com/microsoft/vswhere/wiki/Find-VC#batch 6 7set "vswhere=%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe" 8if not exist "%vswhere%" ( 9 echo Failed to find "vswhere.exe". Please install the latest version of Visual Studio. 10 goto :ERROR 11) 12 13set "InstallDir=" 14for /f "usebackq tokens=*" %%i in ( 15 `"%vswhere%" -latest ^ 16 -products * ^ 17 -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 ^ 18 -property installationPath` 19) do ( 20 set "InstallDir=%%i" 21) 22if "%InstallDir%" == "" ( 23 echo Failed to find Visual C++. Please install the latest version of Visual C++. 24 goto :ERROR 25) 26 27call "%InstallDir%\VC\Auxiliary\Build\vcvars64.bat" || goto :ERROR 28 29set /a errorno=0 30goto :END 31 32:ERROR 33 34:END 35exit /B %errorno% 36