title: How to install postgres with NSIS with all parameters?
body: <p>We have a C# program which uses postgres as its database, so we want to bundle the postgres in the installer as a semi-silent install, i.e. the user will be notified  about the mandatory installation, but the installation itself will be automatically performed without the need for user input.</p>
  
  <p>After researching opinions on WiX, Inno Setup and NSIS we decided to use NSIS.
  As I see it the easiest way will be to include the binary .zip distibution of postgres and perform the following in the script:</p>
  
  <ol>
  <li>Copy the pgsql folder to the installation dir</li>
  <li>Run initdb.exe with the appropriate arguments to create the database itself in InstallDir/pgsql/data</li>
  <li>Run pg_ctl.exe to register as a service with application specific name</li>
  <li>Use the NSIS Simple Service Plugin to start the service</li>
  <li>Install our program</li>
  </ol>
  
  <p>I have several questions about this scenario:</p>
  
  <p><strong>Q1:</strong> Am I on the right track at all?</p>
  
  <p><strong>Q2:</strong> Can I pass the superuser password somehow to initdb.exe, so it doesn't ask the user to enter it trough the console?</p>
  
  <p><strong>Q3:</strong> Where and how do I change the port on which postgres will listen, so that I don't conflict with other installed instances?</p>
  
  <p><strong>Q4:</strong> When uninstalling is it enough to just unregister the service with pg_ctl.exe and delete all folders?</p>
  
  <p>PS: I feel the questions are connected to each other so I've put them all together here. But if needed I can separate them in different questions.</p>