Thursday, September 18, 2008

[GENERAL] Running initdb while logged in as Administrator user (Windows)

I'm trying to develop an automated PostgreSQL installer for Windows that uses a silent install of PostgreSQL and batch scripts to initialise the database cluster (i.e. run initdb) and start/stop the db server. The install shouldn't install as a service, so initdb needs to be run manually.

The problem I'm having is that initdb cannot be run as an Administrator user, so I wrote a script that creates a new limited Windows user and I now want to run initdb using this user, but while still logged in as the Administrator user.
I've looked at using the RUNAS comand, but the user password has to be inserted manually when using this. I've also tried to pipe in the password using echo *** | RUNAS... where *** is the password, but this doesn't seem to work.

I know there are some apps out there that function as alternatives to RUNAS but some of them require licences, and I'm looking for a distributable solution.

How does the PostgreSQL installer work around this when a new limited user can be specified when installing as a service?

Thanks,
Daniel.

No comments: