Skip to content

Instantly share code, notes, and snippets.

@jpluimers
Created July 28, 2014 08:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jpluimers/3ddf9c1edd9ee39cc9bb to your computer and use it in GitHub Desktop.
Save jpluimers/3ddf9c1edd9ee39cc9bb to your computer and use it in GitHub Desktop.
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