@ECHO OFF
rem **********************************************************
rem * Simple bat file to assist invoking the PG_DUMP command *
rem * with the proper password.                              *
rem **********************************************************
rem * Parameter order:                                       *
rem * 1) format                                              *
rem * 2) file                                                *
rem * 3) host                                                *
rem * 4) username                                            *
rem * 5) password                                            *
rem * 6) database                                            *
rem * 7) port                                                *
rem **********************************************************
set PATH_TO_POSTGRES="C:\Program Files\PostgreSQL"
set PATH_TO_PGDUMP="%PATH_TO_POSTGRES%\13\bin"
IF NOT EXIST "%PATH_TO_PGDUMP%" set PATH_TO_PGDUMP="%PATH_TO_POSTGRES%\12\bin"
IF NOT EXIST "%PATH_TO_PGDUMP%" set PATH_TO_PGDUMP="%PATH_TO_POSTGRES%\11\bin"
IF NOT EXIST "%PATH_TO_PGDUMP%" set PATH_TO_PGDUMP="%PATH_TO_POSTGRES%\10\bin"
IF NOT EXIST "%PATH_TO_PGDUMP%" set PATH_TO_PGDUMP="%PATH_TO_POSTGRES%\9.6\bin"
IF NOT EXIST "%PATH_TO_PGDUMP%" set PATH_TO_PGDUMP="%PATH_TO_POSTGRES%\9.5\bin"
IF NOT EXIST "%PATH_TO_PGDUMP%" set PATH_TO_PGDUMP="%PATH_TO_POSTGRES%\9.4\bin"
IF NOT EXIST "%PATH_TO_PGDUMP%" set PATH_TO_PGDUMP="%PATH_TO_POSTGRES%\9.3\bin"
IF NOT EXIST "%PATH_TO_PGDUMP%" set PATH_TO_PGDUMP="%PATH_TO_POSTGRES%\9.0\bin"
IF NOT EXIST "%PATH_TO_PGDUMP%" set PATH_TO_PGDUMP="%PATH_TO_POSTGRES%\8.4\bin"
IF NOT EXIST "%PATH_TO_PGDUMP%" set PATH_TO_PGDUMP="%PATH_TO_POSTGRES%\8.3\bin"
IF NOT EXIST "%PATH_TO_PGDUMP%" set PATH_TO_PGDUMP="%PATH_TO_POSTGRES%\8.2\bin"
IF NOT EXIST "%PATH_TO_PGDUMP%" set PATH_TO_PGDUMP="%PATH_TO_POSTGRES%\8.1\bin"
set PGPASSWORD=%5
IF "%7"=="" "%PATH_TO_PGDUMP%\pg_dump" --format=%1 --file=%2 --verbose --host=%3 --username=%4 %6
IF NOT "%7"=="" "%PATH_TO_PGDUMP%\pg_dump" --format=%1 --file=%2 --verbose --host=%3 --port=%7 --username=%4 %6

