105

I downloaded installer postgresql-9.0.1-1-windows.exe from the official site, ran it, and then got an error:

An error occurred executing the Microsoft VC++ runtime installer

What is the reason for this error message?

Platform: Windows XP SP3, Dell Inspiron 1501. Processor: AMD Sempron 3500+

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
vmg
  • 9,920
  • 13
  • 61
  • 90

14 Answers14

273

One of the reasons this can happen is because the installer attempts to install an older version of the VC++ runtime than what you are currently using.

See this installation log, found in your user's temporary directory (e.g. dd_vcredist_amd64_20190214193107.log):

[20C0:20E4][2019-02-14T19:31:07]e000: Error 0x80070666: Cannot install a product when a newer version is installed.

A workaround is to prevent the runtimes from installing with the --install_runtimes option:

postgresql-9.6.12-1-windows-x64.exe --install_runtimes 0
Rob
  • 45,296
  • 24
  • 122
  • 150
Milen A. Radev
  • 60,241
  • 22
  • 105
  • 110
  • Gives me `There has been an error. Error running XXX\getlocales.exe : Program ended with an err or exit code` on 9.6 and 10.6. – Grim Dec 05 '18 at 15:54
  • 10
    2019 and I encountered the same issue installing version postgresql-11.1-1-windows-x64.exe. Launching it with --install_runtimes 0 definitely solved the problem. – jakejgordon Jan 12 '19 at 02:16
72
  1. Create a shortcut of the downloaded file:

    Enter image description here

  2. Right click of the shortcut → PropertiesShortcut. Add --install_runtimes 0 to the end of the file path:

    Enter image description here

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Mohammad Atiour Islam
  • 5,380
  • 3
  • 43
  • 48
16
  • Create a shortcut of your EXE file;
  • right click on the shortcut → add --install_runtimes 0 at the end of the target path, e.g.:

    postgresql-9.3.1-1-windows-x64.exe --install_runtimes 0
    
  • save and run it :)

Peet Whittaker
  • 750
  • 6
  • 31
user2889858
  • 161
  • 1
  • 3
4

First download and install Microsoft Visual C++ from the Microsoft website. Then run the installation from command with --install_runtimes 0.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Thakhani Tharage
  • 1,288
  • 16
  • 19
3

In my case, when I was installing postgresql-11.0-1-windows-x64.exe on Windows 10, I had faced the same problem.

I just uninstalled the Microsoft Visual C++ Redistributable (the latest one for both 32 and 64 bit) and then tried to install postgresql-11.0-1-windows-x64.exe again, and it worked for me.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
aust_anik
  • 29
  • 4
3

I was having a similar issue and found a fix that worked for me from Garrett_H in this forum post:

http://forums.enterprisedb.com/posts/list/1747.page#6180

Go to file %windir%\inf\wsh.inf, right click and select 'Install'

re-run postgresql installer

I'm running Windows XP Pro, and I was trying to install postgresql-8.3.17-1-windows.exe. I originally received the following error:

An error occurred executing the Microsoft C++ runtime installer.

Community
  • 1
  • 1
Bryan Downing
  • 15,194
  • 3
  • 39
  • 60
  • 1
    The link is (effectively) broken (it redirects to a generic place). – Peter Mortensen Oct 22 '19 at 07:12
  • Looks like that forum is long gone. Best I could find was this wayback machine link: https://web.archive.org/web/20160427090126/http://forums.enterprisedb.com/posts/list/1747.page – Bryan Downing Oct 28 '19 at 19:56
2

Take special care that your Windows user's folder name does not contain spaces. PostgreSQL (as of version 9.2.2.1) handles that poorly. If I use this account on Windows XP, installation fails with the "An error occurred executing the Microsoft C++ runtime installer" message:

"C:\Documents and settings\Jimmy (admin)"

But it runs just fine with this:

"C:\Documents and settings\Jimmy-admin"

The spaces in "Documents and settings" don't seem to bother the installer. Go figure.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
2

Go to file %windir%\inf\wsh.inf, right click, and select 'Install'.

Then re-run the PostgreSQL installer.

This works on Windows XP with PostgreSQL 8.4.17-1.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
2

Try installing as administrator (using Run as administrator).

In version 9.0. PostgreSQL can be installed as a Windows administrator :)

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
basarat
  • 261,912
  • 58
  • 460
  • 511
2

Check if Windows Script Host (WSH) is enabled. If not enabled, details are here: PostgreSQL Installation Problem on Windows without WSH

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Igor P
  • 21
  • 1
2

I too faced the same issue. I fixed it in the following way:

  1. I visited the below site: https://www.enterprisedb.com/downloads/postgres-postgresql-downloads
  2. Choose the Download button under PostgreSQL Version 11.1 for Windows x86-64.

In one word, just try to install the latest version.

1

Windows Script Host (WSH) is unable to execute VBScript scripts. This can occur if the scripting host is disabled (which is unusual), or if the installation is broken. A sign of this problem is a message like

CScript Error: Can't find script engine "VBScript" for script "C:....

It can often be resolved by re-registering the VBScript interpreter, click Start * → * Run and enter the following and click OK:

regsvr32 %systemroot%\system32\vbscript.dll
Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
evan_
  • 11
  • 1
  • 4
0

I had the same problem while trying to install PostgreSQL version 11.1. I had to uninstall the Microsoft VC++ and run the installer again. It downloaded the required VC++ and the installation went successful.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Tony Okoth
  • 157
  • 1
  • 4
0

I had these same problems and tried

  • manually installing MS VC++
  • bypassing VC++ installation on postgres
  • fixing windows update service

Still unsuccessful

Then I solved these problem by installing postgres manually:

  • extract the PostgreSQL installation contents to C:\PostgreSQL (you can copy from successful installation on other machines)
  • add C:\PostgreSQL\bin to PATH environment
  • run pg_ctl register -D D:\pgdata -N postgresql -U postgres -P <your postgres password>
Irfan Kamil
  • 71
  • 1
  • 3