@echo off
rem Joins the bf2.askdavis.com Battlefield 2 server.
rem If BF2 is not found, set BF2DIR below to your install folder.
set "BF2DIR="
for /f "tokens=2,*" %%A in ('reg query "HKLM\SOFTWARE\WOW6432Node\Electronic Arts\EA Games\Battlefield 2" /v InstallDir 2^>nul') do set "BF2DIR=%%B"
if not defined BF2DIR for /f "tokens=2,*" %%A in ('reg query "HKLM\SOFTWARE\Electronic Arts\EA Games\Battlefield 2" /v InstallDir 2^>nul') do set "BF2DIR=%%B"
if not defined BF2DIR if exist "%ProgramFiles(x86)%\EA GAMES\Battlefield 2\BF2.exe" set "BF2DIR=%ProgramFiles(x86)%\EA GAMES\Battlefield 2"
if not defined BF2DIR if exist "%ProgramFiles%\EA GAMES\Battlefield 2\BF2.exe" set "BF2DIR=%ProgramFiles%\EA GAMES\Battlefield 2"
if not defined BF2DIR (
  echo Could not find Battlefield 2. Open this file in Notepad and set BF2DIR to your install folder.
  pause
  exit /b 1
)
cd /d "%BF2DIR%"
start "" "BF2.exe" +menu 1 +restart 1 +joinServer bf2.askdavis.com +port 16567
