@echo off setlocal set "DB_NAME=VisureDB" set "DB_USER=postgres" set "DB_PASS=PASSWORD" set "DB_HOST=localhost" set "DB_PORT=5432" set "DB_VERSION=17" cd /d "C:\Program Files\PostgreSQL\%DB_VERSION%\bin" || ( echo Failed to change directory to PostgreSQL bin. exit /b 1 ) echo Starting VACUUM ANALYZE on main VisureDB_Schema tables... rem === IMPORTANT: keep the next line as ONE SINGLE LINE (no breaks) === psql -h "%DB_HOST%" -p "%DB_PORT%" -U "%DB_USER%" -d "%DB_NAME%" -c "VACUUM (ANALYZE);" rem === Capture exit code from psql === set "ERR=%ERRORLEVEL%" if not "%ERR%"=="0" goto :error echo VACUUM_ANALYZE_completed successfully. goto :eof :error echo VACUUM_ANALYZE_failed with errorlevel %ERR%. exit /b %ERR% :eof set "DB_PASS=" endlocal