postgresql - Executing batch file for postgre dbinit with NSIS gives permission denied -


following previous question i'm trying execute batch file trough nsis code in order setup postgres installation after being unzipped. batch file contains command initializing database fails because of permission restrictions. on win7 x64 pc. user account administrator , start setup.exe run adminitrator option. error get:

c:\program files (x86)\poker assistant>cd "pgsql\bin" c:\program files (x86)\poker assistant\pgsql\bin>initdb -u postgres -a password --pwfile "pwd.txt" -e utf8 -d "..\data" files belonging database system owned user "mandarinite".

this user must own server process.

the database cluster initialized locale "bulgarian_bulgaria.1251". initdb: not find suitable text search configuration locale "bulgarian_ bulgaria.1251" default text search configuration set "simple".

data page checksums disabled.

creating directory ../data ... initdb: not create directory "../data": permission denied

edit: after tinkering little more installer got root of problem. cannot in way execute following command when installation in program files folder:

initdb -u postgres -a password --pwfile "pwd.txt" -e utf8 -d "..\data" 

i tried .bat file. tried .cmd file. tried manually command prompt. tried start administrator. attempts resulted in permission denied error

edit2: did not find way fix problem made workaround. distribute postgres data directory initialized. need create service , start it.

i realised issue here is.

if run postgres administrator, uses special windows api call drop permissions (acquire restricted token), runs without full administrator rights security. see postgresql utilities , restricted tokens on windows.

i suspect what's happening here initdb isn't creating target data directory , setting permissions before doing that, drops permissions , doesn't have permissions create data directory.

to work around it, md ..\data create empty directory , use icacls.exe grant appropriate permissions before try initdb. or, better, store in more appropriate place %programdata%\myapp\pgdata or whatever; application data should not go in %programfiles%.


Comments

Popular posts from this blog

powershell Start-Process exit code -1073741502 when used with Credential from a windows service environment -

twig - Using Twigbridge in a Laravel 5.1 Package -

c# - LINQ join Entities from HashSet's, Join vs Dictionary vs HashSet performance -