PostgreSQL on Windows: psql expects me to log in with my Windows account

Solution 1:

The PGUSER environment variable is considered when the -U option is not set.

So you may use a batch file essentially doing:

set PGUSER=postgres
psql

or set it permanently as mentioned in other questions such as Change environment variables as standard user.

In fact there are quite a few other variables corresponding to other connection properties that can be set similarly (see Environment Variables in the PostgreSQL documentation for the full list).

These variables are a feature of libpq, the DLL implementing the client-server interaction for most PostgreSQL applications, so they will work not just for psql but for all these applications.