10

I've been trying to install the 64bit version of PostgreSQL 9.2 for Windows on my machine (Windows 7 64bit) and get this error:

The environment variable COMPSPEC does not seem to point to the cmd.exe or there is a trailing semi colon present.

I've installed it as Administrator.

I disabled the antivirus (Microsoft Security Essentials) and the firewall.

Running:

"%COMSPEC%" /C "echo test ok"

returned test ok

I've checked my System Environment Variables for trailing semi colon and I couldn't find any.

I then installed the 32bit version and managed to get to the end of the install with a different error message stating: Problem running post-install step. Installation may not complete correctly Error reading the C:\Program Files (x86)\PostgreSQL\9.2\data\postgresql.conf but there is no postgresql.conf file in that directory. It did install the application and when I try to connect the server with the red X on it it says fail at the bottom and it won't connect after I type in my password.

How can I connect to this server connection?

12 Answers 12

20

ComSpec is a generic error message for any installation failure.

Identifying the problem

  1. Navigate to below path c:\Users\XXXXXX\AppData\Local\Temp
  2. Open 'bitrock_installer_XXXX.log'
  3. Check, if you are getting below error:

Script stderr: '"C:\Users\XXXXX\AppData\Local\Temp\POSTGR~1\TEMP_C~1.BAT"' is not recognized as an internal or external command, operable program or batch file.

Error running

C:\Users\XXXXX\AppData\Local\Temp/postgresql_installer_47b21c4ea1/temp_check_comspec.bat :
'"C:\Users\XXXXX\AppData\Local\Temp\POSTGR~1\TEMP_C~1.BAT"' is not recognized as an internal or external command,

operable program or batch file.

This is a problem with '8.3 file names and directories' (e.g. '\Postgres Install' -> '\POSTGR~1') Microsoft article on disabling 8.3 file names and directories: https://support.microsoft.com/en-gb/kb/121007

Solution:

  1. Open command prompt in admin mode
  2. Execute following command to change the format based on your drive or all drives

    Sample commands:

    fsutil 8dot3name set 1"      - disable 8dot3 name creation on all volumes
    fsutil 8dot3name set C: 1"   - disable 8dot3 name creation on c:
    
  3. Execute the installation as a user having admin privileges

  4. After install, consider resetting the 8dot3name setting to default (2) to avoid unintended consequences

Hope it solves the problem!

Sign up to request clarification or add additional context in comments.

5 Comments

Thanks this fixed my problem on windows 10.
Installing PostgreSQL 10.1 on Windows 10, I found out that the 'bitrock_installer_XXXX.log' file was under C:\temp. I followed the rest of your protocol and it worked fine. Thanks.
How do you reset to default?
Installing postgres 12.2 on windows7, I couldn't find updated bitrock_installer_XXXX file, but changing fsutil still worked and fixed the installation
use this method if you have an ibm. i tried the easier methods first which still didn't work such as verifying comspec env var was correct, running install in admin, moving .exe from downloads to desktop, but once i ran fsutil 8dot3name set C: 1" then it finally worked. i just wish i knew how to undo the command now that it is installed. hehehe
2

Very easy fix:

  1. Just open Advanced System Settings in Control Panel and create a new System Variable( in the System Variable instead of User Variable section).

  2. In the variable name, enter ComSpec and then in the variable value , enter C:\Windows\system32\cmd.exe.

Alternative fix:

If you have already the ComSpec variable in the System Variable section, remove the ;at the end of it this should fix it.

Comments

1

It's not COMPSPEC it's just COMSPEC. Please show the output of:

echo %COMSPEC%

Note that COMSPEC could be set to something different in the Administrator account you're running the installer as. I'm not sure how to find that out, but it might appear in the PostgreSQL installer log, so please upload that and link to it in your post. See Reporting an installation error for info on where to get the installer log.

See the PostgreSQL for Windows FAQ entry Check the COMSPEC environment variable.

Here's a report I made suggesting that the installer should test for this explicitly and here's my blog post on the topic.

10 Comments

Under System variables, ComSpec, there is no trailing semicolon "%SystemRoot%\system32\cmd.exe". And the result of the echo %COMSPEC% returns: C:\Windows\system32\cmd.exe
I've managed to install the same executable on my laptop and PostgreSQL 9.2 works fine. But on my desktop i still can't get it to install.
@user2147063 Please upload the installer log from the problem machine somewhere and post a link to it in a comment. Instructions on finding the installer log are in my answer. Without the installer log I can not help you.
@user2147063 Aah, that's the 32-bit installer log. Can you get the 64-bit one? It's probably the older file install-postgresql.log without the (1). It's the error with the 64-bit version that you asked about re COMSPEC, so having the correct log would help. So far it looks like some program installer has probably screwed up the registry for the true Administrator user (not the UAC wrapper for it), changing COMSPEC in its environment only.
Yeah both versions won't work at different places during the install. You mention "program installer has probably screwed up the registry for the true Administrator user", is there a way to work from there, as in working with the registry??
|
1

I got the same problem, and i found in the log:

Script stderr: 'C:\Users\S300' is not recognized as an internal or external command, operable program or batch file.

Error running C:\Users\S300 (i5)\AppData\Local\Temp/postgresql_installer_56caeadbd6/temp_check_comspec.bat : 'C:\Users\S300' is not recognized as an internal or external command, operable program or batch file.

I change in User Variables TEMP to D:\TEMP and TMP to D:\TEMP. And Solved My Problem.

Comments

1

In my case , the Installer was in %USERPROFILE%\DownloadsP{ Windows download folder}, I moved the installer to desktop and ran again. weird it worked lol.

Comments

0

I had a similar problem. After installation, the data folder contained no postgres.conf file. It only contained a single folder named "pg_log". I described the solution that I used here: Postgres Installation Error reading file postgresql.conf

Basically, it would be helpful to check if the user has full permissions for the postgres folder, and run "init_db" and "pg_ctl start" commands again. If the path contains a space character, try using a relative path for the pg_ctl data folder argument.

Comments

0

I'm running Windows Server 2003 R2, and I have been unable to resolve this problem with the installer, so I resorted to using the binary PostgreSQL package. Hopefully this will be an alternative for others who do not want to perform an OS reinstall.

First, some background (hopefully useful to the developers)

It started out with the postgres service failing to start (the server had been running reliably for over a year). I assumed it was a corrupted PostgreSQL installation, so I uninstalled and attempted to reinstall. I encountered the following error:

There has been an error.
The environment variable COMSPEC does not seem to point to the cmd.exe or there is a trailing semicolon present.
Please fix this variable and restart installation.

However, the COMSPEC variable is set properly, verified with:

echo %COMSPEC%
C:\WINDOWS\system32\cmd.exe

and:

"%COMSPEC%" /C "echo test ok"
test ok

Since this is Windows Server 2003, there is no UCA wrapper around the Administrator account, so that is not causing the problem.

Manual Installation

NET USER postgres /ADD

C:\pgsql\bin\initdb.exe -U postgres -A password -E utf8 -W -D C:\pgsql\data

runas /user:postgres "C:\pgsql\bin\pg_ctl -D C:/pgsql/data -l C:/pgsql/logfile.txt start"

Comments

0

just do it run as administrator and change the environment system variable like create a new variable 'ComSpec' and value type 'C:\Windows\system32\cmd.exe'.

Comments

0

If the installer exe is on a network share that mapped drive might actually not be accessible to the installer as it runs as administrator. This can often happen in some virtual machine arrangements such as running windows in a parallels VM. Copy the installer to a local drive first and you won't have a problem.

Comments

0

What worked for me after trying to enter the commandline given her in cmd.exe I found it was named cmd1.exe in system32.. so i copied the file and renamed it as cmd.exe and installation finished

Comments

0

Open Environment Variables, you can do this on Windows 7 by typing environment variables in the Search program and files bar when pressing the start button at the bottom left of the desktop. And create a new System Variable(in the 'System Variable' instead of 'User Variable' section).

In the variable name, enter ComSpec and then in the variable value , enter C:\Windows\system32\cmd.exe.

That's all. Hope it works! Alternative fix:

If you already got the ComSpec variable in the System Variable section, remove the ; at the end of it this should fix it.

Comments

-1

First find the path to cmd.exe(mostly it is C:\Windows\System32\cmd.exe). Go to the enviornment variable and add this path to system variable path.And also create new variable in user variable called ComSpec and add this path as value. And you are ready to go.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.