cancel
Showing results for 
Search instead for 
Did you mean: 

One cause for the Postgres installer to hang on Windows

Highlighted
Level 3 Traveller

One cause for the Postgres installer to hang on Windows

I am sharing a solution to an obscure problem that can prevent the installation of Postgres on Windows from completing. I hope my small contribution to the community helps someone, somewhere...

 

I spent much of last evening trying to install PG 10.7 on my aging Windows 7 box. The installer would copy all the files and then display this:

 

Initalizing the database cluster (this may take a few minutes)...

Many minutes pass and it becomes apparent that it is stuck on something. The usual Google search turns up some posts seemingly about this, but they all discuss permissions issues, and I know a permission failure is unlikely to cause a hang. This is confirmed when I look in Process Explorer. In the subtree under the installer .exe, I see this:

 

C:\Windows\system32\cscript.exe //NoLogo "C:\Program Files (x86)\PostgreSQL\10/installer/server/initcluster.vbs" "NT AUTHORITY\NetworkService" postgres ZZZZ "C:\Program Files (x86)\PostgreSQL\10" "C:\Program Files (x86)\PostgreSQL\10\data" 5432 DEFAULT 0
    "C:\Windows\system32\NOTEPAD.EXE" C:\Users\XXX\AppData\Local\Temp\radD8385.bat

 

It's running a script that is starting Notepad on a temporary file with a BAT script. I assume the Notepad window is not visible because of some MSI Voodoo. Whatever. I look at initcluster.vbs and it has no mention of notepad. Hmmm. Further digging reveals it uses the Windows Scripting Host Shell "Run" function to "run" the BAT file. "Run" hands the file to the application associated with the file extension and saying "here, run this." And that was why the Postgres installer got stuck.

 

By default, Windows associates BAT files with the BAT file interpreter. However, on my Windows 7 box, BAT files were associated with Notepad. Double-click on a BAT file, and you get an editor window. It prevents accidentally running a file, but it turns out that causes a particular installer to fail! This machine has had this file association for years, and it never caused any problems until now.

 

I did get the installer to run successfully after I un-associated BAT files with Notepad. That simple-sounding task turned out to be incredibly hard to figure out. The Windows GUI tools are useless for this particular task. They don't offer the option of removing a file association, only adding or changing. You need to edit the Registry (yuck):

 

* Run regedit.exe As Administrator.

* Open HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.bat

* Edit so you end up with the following configuration:

key .bat
    value (Default) = REG_SZ (value not set)
    key OpenWithList
        value (Default) = REG_SZ (value not set)
        key OpenWithProgIDs
            value (Default) = REG_SZ (value not set)
            value batfile = REG_NONE (zero-length binary value)

* When .BAT files are associated with an application you will have additional keys and values. Delete them.

 

Some Internet advice says running the "assoc" command (As Administrator) will fix this kind of problem, but that is not true for "built-in" types like BAT.

1 REPLY 1
Community Manager

Re: One cause for the Postgres installer to hang on Windows

Thank you, Blueman, for sharing this with the community for us all to learn from!

We appreciate the thoughtful work and insights. Very helpful contribution!

 

Lori