Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have a pgpass.conf file that works well for my default user. It is in C:/Users/myuser/AppData/Roaming/postgresql/pgpass.conf. It reads like so;

localhost:5432:*:postgres:password1

I have a process that runs under the Administrator account. When I run whoami under this process I get nt authority/system. I want to be able to access the database from this process but it gets stuck because it needs a password. I have tried putting the above pgpass.conf into C:/Users/Administrator/AppData/postgresql/pgpass.conf and C:/Users/Administrator/AppData/Roaming/postgresql/pgpass.conf but it does not work. Is this the correct place for this file? Am I even able to do this as the Administrator. Unfortunately I cannot change the user that this process runs under.

share|improve this question
add comment

1 Answer 1

up vote 2 down vote accepted

See what echo %APPDATA% outputs when you're logged with this account.

As an alternative, you can point the PGPASSFILE environment variable to the location of the file, wherever it it, or even set the PGPASSWORD environment variable with the password itself to avoid that file altogether.

The Environment Variables and The Password File sections from the doc give the details.

share|improve this answer
    
Beautiful thankyou. I couldn't face trying to configure my process to run that echo command so went with the PGPASSFILE option. Problem solved. –  brad Sep 24 '12 at 2:58
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.