Skip to content

Instantly share code, notes, and snippets.

@jpluimers jpluimers/tf.bat
Created Jul 28, 2014

Embed
What would you like to do?
Find an installed tf.exe, then run it with the command-line parameters specified.
@echo off
setlocal
IF /I %PROCESSOR_ARCHITECTURE% == amd64 goto :x64
IF /I %PROCESSOR_ARCHITEW6432% == amd64 goto :x64
goto :x86
:x64
:: OS is 64bit
set vsBaseKey=HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\VisualStudio\
goto :findTF
:x86
:: OS is 32bit
set vsBaseKey=HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\
goto :findTF
:findTF
:: https://gist.github.com/rojepp/634908
:: http://stackoverflow.com/questions/5369528/windows-batch-reg-query-key-value-to-a-variable-but-do-not-display-error-if-key
set SupportedVisualStudioVersions=8.0, 9.0, 10.0, 11.0, 12.0, 13.0
for %%v in (%SupportedVisualStudioVersions%) do (
for /f "usebackq tokens=2* delims= " %%c in (`reg query "%vsBaseKey%%%v" /v InstallDir 2^>NUL`) do (
set tfExe=%%dtf.exe
)
)
if "%tfExe%"=="" ( echo no TF.exe found ) else (
if not exist "%tfExe%" echo not found: "%tfExe%"
if exist "%tfExe%" "%tfExe%" %*
)
endlocal
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.