@echo off :: Batch file to run Visual Studio with CAFE_ROOT_DOS set locally :: The name must be: foo.sln.bat :: where foo.sln is the target file to open with devenv. :: CAFE_ROOT_DOS is figured out automatically, :: assuming the current directory contains "\system\src\tool" :: We'll remove everything after *\system\src\tool from CD. Step 1: set _endbit=%CD:*\system\src\tool=% :: Step 2. Now remove that end bit from the current path: call set _result=%%CD:%_endbit%=%% :: CAFE_ROOT is three levels up from there :: (we didn't want to match only "system" as it might not be unique enough) set CAFE_ROOT_DOS=%_result%\..\..\.. :: Start devenv (using an environment var it always set upon installation) start "%VS90COMNTOOLS%..\IDE\devenv.exe" %~n0