Last active
March 25, 2025 14:44
-
-
Save lboulard/a8083db3d23d84df2800c9641867a654 to your computer and use it in GitHub Desktop.
DOS batch script to setup up VS2002 in x86/Win32 platform (can be used with CLion Toolchain settings)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@REM For Clang with x86 Windows SDK | |
@SETLOCAL ENABLEEXTENSIONS ENABLEDELAYEDEXPANSION | |
@SET "InstalledRoot=HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows Kits\Installed Roots" | |
@FOR /F "skip=2 tokens=2*" %%i IN ('reg query "%%InstalledRoot%%" /v KitsRoot10') DO @( | |
@SET "SDK_ROOT=%%j" | |
) | |
@IF "%SDK_ROOT%" == "" @( | |
ECHO>&2.No Installed Windows SDK found | |
EXIT /B 1 | |
) | |
@IF "%SDK_ROOT:~-1%" == "\" SET "SDK_ROOT=%SDK_ROOT:~0,-1%" | |
@IF NOT EXIST "%SDK_ROOT%\." @( | |
@ECHO>&2.!SDK_ROOT:(=^(!: does not exist | |
@EXIT /B 1 | |
) | |
@FOR /F "skip=1 delims=\\ tokens=6" %%j in ('reg query "%%InstalledRoot%%" /k /f 10*') DO @( | |
@SET "SDK_VERSION=%%j" | |
) | |
@IF "%SDK_VERSION%" == "" @( | |
@ECHO>&2.No Windows SDK installation candidate found | |
@EXIT /B 1 | |
) | |
@SET "WINDOWS_SDK=%SDK_ROOT%\bin\%LAST_VERSION%" | |
@IF NOT EXIST "%WINDOWS_SDK%\." ( | |
@ECHO>&2.!WINDOWS_SDK:(=^(!: installation kit does not exist | |
@EXIT /B 1 | |
) | |
@ENDLOCAL&SET "WINDOWS_SDK_ROOT=%SDK_ROOT%"&SET "WINDOWS_SDK_VERSION=%SDK_VERSION% | |
SET "INCLUDE=%WINDOWS_SDK_ROOT%\Include\%WINDOWS_SDK_VERSION%\ucrt;%INCLUDE%" | |
SET "INCLUDE=%WINDOWS_SDK_ROOT%\Include\%WINDOWS_SDK_VERSION%\um;%INCLUDE%" | |
SET "INCLUDE=%WINDOWS_SDK_ROOT%\Include\%WINDOWS_SDK_VERSION%\shared;%INCLUDE%" | |
SET "LIB=%WINDOWS_SDK_ROOT%\lib\%WINDOWS_SDK_VERSION%\um\x64;%LIB%" | |
SET "LIB=%WINDOWS_SDK_ROOT%\lib\%WINDOWS_SDK_VERSION%\ucrt\x64;%LIB%" | |
PATH %WINDOWS_SDK_ROOT%\bin\x64;%PATH% | |
PATH %WINDOWS_SDK_ROOT%\bin\%WINDOWS_SDK_VERSION%\x64;%PATH% | |
PATH %ProgramFiles%\LLVM\bin;%PATH% |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@REM For Clang with x86 Windows SDK | |
@SETLOCAL ENABLEEXTENSIONS ENABLEDELAYEDEXPANSION | |
@SET "InstalledRoot=HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows Kits\Installed Roots" | |
@FOR /F "skip=2 tokens=2*" %%i IN ('reg query "%%InstalledRoot%%" /v KitsRoot10') DO @( | |
@SET "SDK_ROOT=%%j" | |
) | |
@IF "%SDK_ROOT%" == "" @( | |
ECHO>&2.No Installed Windows SDK found | |
EXIT /B 1 | |
) | |
@IF "%SDK_ROOT:~-1%" == "\" SET "SDK_ROOT=%SDK_ROOT:~0,-1%" | |
@IF NOT EXIST "%SDK_ROOT%\." @( | |
@ECHO>&2.!SDK_ROOT:(=^(!: does not exist | |
@EXIT /B 1 | |
) | |
@FOR /F "skip=1 delims=\\ tokens=6" %%j in ('reg query "%%InstalledRoot%%" /k /f 10*') DO @( | |
@SET "SDK_VERSION=%%j" | |
) | |
@IF "%SDK_VERSION%" == "" @( | |
@ECHO>&2.No Windows SDK installation candidate found | |
@EXIT /B 1 | |
) | |
@SET "WINDOWS_SDK=%SDK_ROOT%\bin\%LAST_VERSION%" | |
@IF NOT EXIST "%WINDOWS_SDK%\." ( | |
@ECHO>&2.!WINDOWS_SDK:(=^(!: installation kit does not exist | |
@EXIT /B 1 | |
) | |
@ENDLOCAL&SET "WINDOWS_SDK_ROOT=%SDK_ROOT%"&SET "WINDOWS_SDK_VERSION=%SDK_VERSION% | |
SET "INCLUDE=%WINDOWS_SDK_ROOT%\Include\%WINDOWS_SDK_VERSION%\ucrt;%INCLUDE%" | |
SET "INCLUDE=%WINDOWS_SDK_ROOT%\Include\%WINDOWS_SDK_VERSION%\um;%INCLUDE%" | |
SET "INCLUDE=%WINDOWS_SDK_ROOT%\Include\%WINDOWS_SDK_VERSION%\shared;%INCLUDE%" | |
SET "LIB=%WINDOWS_SDK_ROOT%\lib\%WINDOWS_SDK_VERSION%\um\x86;%LIB%" | |
SET "LIB=%WINDOWS_SDK_ROOT%\lib\%WINDOWS_SDK_VERSION%\ucrt\x86;%LIB%" | |
PATH %WINDOWS_SDK_ROOT%\bin\x86;%PATH% | |
PATH %WINDOWS_SDK_ROOT%\bin\%WINDOWS_SDK_VERSION%\x86;%PATH% | |
PATH %ProgramFiles%\LLVM\bin;%PATH% |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@REM For Win32 | |
@SETLOCAL | |
@REM Path to vswhere.exe | |
@SET VSWHERE="%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe" | |
@IF NOT EXIST %VSWHERE% ( | |
@ECHO.vswhere.exe not found at %VSWHERE% | |
@EXIT /B 1 | |
) | |
@REM Query for latest VS2022 instance | |
@FOR /F "delims=" %%i in ('%VSWHERE% -latest -version [17.0^,18.0^) -property installationPath') DO @( | |
@SET "VS_PATH=%%i" | |
) | |
@ENDLOCAL & SET "VS_PATH=%VS_PATH%" | |
@ECHO Visual Studio 2022 Path: %VS_PATH% | |
@IF NOT EXIST "%VS_PATH%" ( | |
@ECHO.Visual Studio 2022 not found at '%VS_PATH%' | |
@EXIT /B 1 | |
) | |
"%VS_PATH%\VC\Auxiliary\Build\vcvarsall.bat" x86 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment