On Mon, Nov 2, 2015 at 2:54 PM, YuanyuanLiu <liuyuanyuang...@gmail.com> wrote: > Nowadays, I always got problem about postgresql windows service. > I find, postgresql usually use the following command to register windows > services: > /"D:\Program Files (x86)\PostgreSQL\9.4\bin\pg_ctl.exe" runservice -N > "postgresql-9.4" -D "D:\Program Files (x86)\PostgreSQL\9.4\data" -w/ > But this command always failed, beacause of user privilege, just as a > topic described: > http://postgresql.nabble.com/pg-ctl-could-not-start-service-quot-pgsql-8-2-quot-error-code-1063-td1880801.html#a1880802 > While 'pg_ctl start -D ../data' works well, why not to use this command to > register postgresql windows service? why to use 'pg_ctl runservice -N "psql" > -D ".../data"' ? This is really confused me when I use postgresql in > windows.
runservice is not a command that is aimed to be run manually, and that's what your link above refers to. A service should be registered using register, then you should use sc to start the service if you are doing it manually (you may do it automatically that's the default behavior then there is no need to use sc): pg_ctl register -N pg_service_name -D %PGDATA% -S demand sc start pg_service_name Now we could make the code more complicated in the start path to support that. And some users may want to be able to start a server on Windows without having to set up a service that lasts only for the time of a session. For example sometimes I do so for testing purposes. So that's quite handy to not rely on the Windows SCM in this case. -- Michael -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers