(Note: This question has been compeltely rewritten from its original form, so it reflects the actual problem and will help others find a solution to the same issue).

I still haven't been able to successfully install PostgreSQL on my Windows 7 Ultimate x64 computer. See this prior question for some history.

I did a fresh instillation of 9.2 and the only error I got was this one:

error installing

It reads:

"Problem running post-install step. Installation may not complete correctly. The database cluster initialisation failed".

This occurs even after I do a complete manual uninstall of PostgreSQL and pgAmdin-III:

  • Ran the PostgreSQL uninstaller, which failed with the error Error stopping service postgresql-x64-9.2.
  • Removed all the PostgreSQL-related registry entries for PostgreSQL under HKEY_LOCAL_MACHINE\SOFTWARE and HKEY_CURRENT_USER\SOFTWARE
  • Removed the postgres user account using net user postgres /delete in an Administrator command prompt (shift-right clicked on "Command Prompt" in start menu, chose "Run as administrator")
  • Removed the postgres user profile
  • Deleted the C:\Program Files\PostgreSQL\ directory, including the data directory within %appdata%
  • Removed some PgAdmin-III registry entries that pointed to PostgreSQL
  • Removed the service account for postgres from services.msc

When I reboot and try the installer again it fails with the same message.

The install-postgresql.log file from %TEMP% contains:

Executing cscript //NoLogo "C:\Program Files\PostgreSQL\9.2/installer/server/initcluster.vbs" "NT AUTHORITY\NetworkService" "postgres" "****" "C:\Program Files\PostgreSQL\9.2" "C:\Program Files\PostgreSQL\9.2\data" 5432 "DEFAULT"
Script exit code: 1

then another error a bit later:

creating template1 database in C:/Program Files/PostgreSQL/9.2/data/base/1 ... initdb: could not execute command ""C:/Program Files/PostgreSQL/9.2/bin/postgres.exe" --boot -x1 -F ": No error

See full installer log file download here.


It appears that the root cause of this issue may have been that @Celeritas's computer had an incorrect value for the COMSPEC environment variable. It had a trailing semicolon, so instead of the normal:


it was:


This one-character difference is enough. The above isn't a valid command prompt path, so popen() calls were failing. Unfortunately, instead of something useful like:

'"C:\Windows\system32\cmd.exe;"' is not recognized as an internal or external command, operable program or batch file

it instead reports the delightfully useful error No error:

initdb: could not execute command ""C:/Program Files/PostgreSQL/9.2/bin/postgres.exe" --boot -x1 -F ": No error

See related:

I've reported this to the installer team and written a wiki entry to describe it. See blog post.

The issue was eventually resolved by:

  • Editing the COMSPEC environment variable
  • Uninstalling PostgreSQL
  • Rebooting
  • Reinstalling PostgreSQL

though there was a lot more before that which shouldn't actually be necessary to resolve this, including doing a total manual clean uninstall of PostgreSQL by hand.

Now I just want to find the people who wrote the program that modified this environment variable.


from this answer https://dba.stackexchange.com/a/248584/185153

If you're on Windows 10 with codepage UTF-8 in regional settings (picture in link above), the root cause is that :

  1. Cluster initialization in setup calls initdb
  2. initdb checks version as if calling postgres -V
  3. postgres -V doesn't recognise CPutf8 yet then returns an unmatched result.

Until it is properly fixed, you may just uncheck UTF-8 codepage box and restart, it will be okey.

This can reproduced in PostgreSQL 12 also.

Kudos to @simon for this finding.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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