Find an installed tf.exe, then run it with the command-line parameters specified.
Posted by jpluimers on 2015/04/30
Often I want to execute a TF.exe from the console, but don’t have the Visual Studio environment variables setup. Most of the times I want to run TF.exe from the most current Visual Studio installation, hence this TF.bat file figures out the location of it, then runs with the parameters passed to TF.bat:
A few notes:
- I wasn’t sure from which Visual Studio version TF.exe was supported. I thought Visual Studio 2005 or 2008, but got confirmed it was Visual Studio 2005 (a.k.a. 8) by Love the elegance of F#. This code looks for the TFS Command line tool and returns Somepath or None.
- The Visual Studio names and version numbers are a mess, so I usually first look at the Wikipedia Microsoft Visual Studio History table.
- The same holds for many other numbers and registry paths.INFO: Visual Studio version numbers is of great help here.
- The base registry path depends if you are running on an x64 or x86 system I used the PROCESSOR_ARCHITECTURE and PROCESSOR_ARCHITEW6432 environment variables to detect which bitness was running as described in HOWTO: Detect Process Bitness – David Wang – MSDN Blogs (I blogged about that before: Windows batch file to set ProgramFilesX86 directory for 32-bit program files on x86 and x64 systems via: Stack Overflow).
- Since I have no VM that has all these Visual Studio installations installed, reg query usually gives an error message. The 2^>NUL trick gets around that: Windows Batch: reg query key value to a variable but do not display error if key doesn’t exist – Stack Overflow.