Switch between versions of Firebird SQL Server

I wrote a little batch script to switch between versions of Firebird SQL Server nearly automatically.

The only one requirement is that all versions must be installed in C:\Program Files\Firebird\<Version> where is Major.Minor version number of the Firebird Server you want to use.

Eg : C:\Program Files\Firebird\1.5, C:\Program Files\Firebird\2.0, C:\Program Files\Firebird\2.1 ...

Just copy the script in C:\Program Files\Firebird and start switching between versions of Firebird :

C:\Program Files\Firebird\> switch 1.5
C:\Program Files\Firebird\> switch 2.0
...

The code :

@echo off
 
if "%OLD_PATH%" == "" (
  set OLD_PATH=%PATH%
)
 
setlocal
 
set FB_KEY=HKLM\SOFTWARE\Firebird Project\Firebird Server\Instances
set FB_VALUE=DefaultInstance
 
for /F "skip=2 tokens=2*" %%A IN ('reg query "%FB_KEY%" /v %FB_VALUE%') do (
  for /F "delims=\ tokens=4" %%Y IN ('echo %%B') do (
    set CURRENT_FB=%%Y
  )
)
 
set VERSION=%1
 
if "%VERSION%" == "" (
  echo Syntax : %0 [1.5 ^| 2.0 ^| 2.1 ^| 2.5 ^| 3.0] [Params for instsvc i^(nstall^)]
  if not %CURRENT_FB% == "" (
    if exist %CURRENT_FB%\bin\instsvc.exe (
      echo.
      echo Tip : These are the available options for instsvc from Firebird %CURRENT_FB%
      %CURRENT_FB%\bin\instsvc.exe
    )
  )
) else (
  if not "%CURRENT_FB%" == "" (
    echo Unregistering Firebird %CURRENT_FB%
 
    pushd %CURRENT_FB%\bin
    instclient r g
    instsvc stop
    instsvc r
    instreg r
    popd  
 
    echo.
  )
 
  echo Registering Firebird %VERSION%
 
  pushd %VERSION%\bin  
  instreg i -z
  instsvc i %2 %3 %4 %5 %6 %7 %8 %9
  instsvc start
  instclient i g
  popd
 
  echo.
 
  echo Defining System Path to search in Firebird %VERSION% tools and some useful environment variables
 
  endlocal 
  set PATH=%OLD_PATH%;"%CD%\%VERSION%\bin"
  set ISC_USER=SYSDBA
  set ISC_PASSWORD=masterkey
 
  echo All Right !
)

Hope this helps 🙂

Be Sociable, Share!

Tags: ,

  1. Jeroen Pluimers’s avatar

    In a comment to a ping-back (http://wiert.wordpress.com/2009/12/05/le-vosgien-du-net-·-switch-between-versions-of-firebird-sql-server) Edwin van der Kraan correctly notices that you also have to watch which version of gds32.dll you are using.

    They are not only different between Firebird and InterBase, but also different across versions of the same product brand.
    —jeroen

Reply

Votre adresse de messagerie ne sera pas publiée. Les champs obligatoires sont indiqués avec *