I test it with PostgreSQL 9.5 like this, and it worked first time. Be sure to run as administrator:
@echo off
for /f "tokens=1-4 delims=/ " %%i in ("%date%") do (
set dow=%%i
set month=%%j
set day=%%k
set year=%%l
)
set datestr=%month%_%day%_%year%
echo datestr is %datestr%
set BACKUP_FILE=test_%datestr%.backup
echo backup file name is %BACKUP_FILE%
SET PGPASSWORD=postgres
echo on
"C:\Program Files\PostgreSQL\9.5\bin\pg_dump" -h 127.0.0.1 -p 5432 -U postgres -F c -b -v -f %BACKUP_FILE% mytestdb