11

I am new to PostgreSQL and when I tried to install PostgreSQL 13 / 14 on my Windows 10 device I encountered the following error.

"The environment variable COMSPEC does not seem to point to the cmd.exe or there is a training semicolon present. Please fix this variable and restart installation." 

The screenshot of the pop up error


COMSPEC System Variable

This is the setting of my COMSPEC environment variable


The Content of the installbuilder_installer.log

Log started 05/06/2022 at 17:51:52
Preferred installation mode : qt
Trying to init installer in mode qt
Mode qt successfully initialized
Setting variable whoami from C:\WINDOWS\System32\whoami 
Script exit code: 0

Script output:
 atrapa\junkwong

Script stderr:
 

Executing C:\WINDOWS\System32\icacls "C:\Users\junkwong\AppData\Local\Temp/postgresql_installer_c7c2d91f40" /inheritance:r
Script exit code: 0

Script output:
 processed file: C:\Users\junkwong\AppData\Local\Temp/postgresql_installer_c7c2d91f40
Successfully processed 1 files; Failed processing 0 files

Script stderr:
 

Executing C:\WINDOWS\System32\icacls "C:\Users\junkwong\AppData\Local\Temp/postgresql_installer_c7c2d91f40" /T /Q /grant "atrapa\junkwong:(OI)(CI)F"
Script exit code: 0

Script output:
 Successfully processed 1 files; Failed processing 0 files

Script stderr:
 

Executing C:\WINDOWS\System32\cscript //NoLogo "C:\Users\junkwong\AppData\Local\Temp\postgresql_installer_c7c2d91f40\prerun_checks.vbs"
Script exit code: 0

Script output:
 The scripting host appears to be functional.

Script stderr:
 

Could not find registry key HKEY_LOCAL_MACHINE\SOFTWARE\PostgreSQL\Installations\postgresql-x64-14 Base Directory. Setting variable iBaseDirectory to empty value
Could not find registry key HKEY_LOCAL_MACHINE\SOFTWARE\PostgreSQL\Installations\postgresql-x64-14 Branding. Setting variable iBranding to empty value
Could not find registry key HKEY_LOCAL_MACHINE\SOFTWARE\PostgreSQL\Installations\postgresql-x64-14 Version. Setting variable brandingVer to empty value
Could not find registry key HKEY_LOCAL_MACHINE\SOFTWARE\PostgreSQL\Installations\postgresql-x64-14 Shortcuts. Setting variable iShortcut to empty value
[17:52:01] Using branding: PostgreSQL 14
Could not find registry key HKEY_LOCAL_MACHINE\SOFTWARE\PostgreSQL\Installations\postgresql-x64-14 SB_Version. Setting variable sb_version to empty value
Could not find registry key HKEY_LOCAL_MACHINE\SOFTWARE\PostgreSQL\Installations\postgresql-x64-14 pgAdmin_Version. Setting variable pgadmin_version to empty value
Could not find registry key HKEY_LOCAL_MACHINE\SOFTWARE\PostgreSQL\Installations\postgresql-x64-14 CLT_Version. Setting variable clt_version to empty value
Could not find registry key HKEY_LOCAL_MACHINE\SOFTWARE\PostgreSQL\Installations\postgresql-x64-14 Data Directory. Setting variable server_data_dir to empty value
Executing C:\Users\junkwong\AppData\Local\Temp/postgresql_installer_c7c2d91f40/temp_check_comspec.bat 
Script exit code: 0

Script output:
 

Script stderr:
 

Exiting with code 1

And the COMSPEC variable is indeed set as a System Variable not a User Variable like many posts proposed. Also, there is no trailing semi colon (;)

What I have tried:

  1. I have ran the "%COMSPEC%" /C "echo test ok" on my command prompt and got "test ok" as result see here
  2. Ran the installation on Administrator cmd.
  3. To install different versions of PostgreSQL including 14.2.2, 14.3.1 and 13.7.1 (all produce the same error message)
  4. Tried out the solution proposed by Prayash Koirala but no Command Processor file can be found Postgresql 9.4 installation/Windows 8.1/ COMSPEC issue
  5. Tried this Problems Installing PostgreSQL 9.2 . but the bitrock_installer_xxxx.log is absent from the suggested path

Thank you very much, any help or suggestions are appreciated.

Have a good day.

Regards,
Jun Kang

1
  • Did you contact the maintainer of the Windows installer? Maybe they made a mistake and now how to fix it Commented May 17, 2022 at 9:38

7 Answers 7

9
  1. Run the following command at a command prompt:

    fsutil behavior set disable8dot3 1

  2. Restart the computer.

This is a solution from https://learn.microsoft.com/en-GB/troubleshoot/windows-server/performance/stop-error-code-0x00000019, it worked for me.

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

Comments

4

I faced this problem once again, and my previous answer didn't work for me this time.

I solved the problem by instead of using classic PostgreSQL installer, I set this up with a Docker.

  1. Install Docker Desktop

    https://www.docker.com/products/docker-desktop/

  2. Start installed Docker Desktop

  3. In PowerShell, run:

    docker pull postgres

  4. In PowerShell, run:

    docker run -d -p 5432:5432 --name postgres -e POSTGRES_PASSWORD=mypassword postgres

  5. Now you can connect to the Postgres server for example with pgAdmin on the same machine, using:

    • host: localhost
    • port: 5432
    • maintenance database: postgres
    • username: postgres
    • password: mypassword

1 Comment

Thanks, after trying the others, this solved the issue for me. One small addition: after step 4, you have to go into the docker container: docker exec -it postgres bash. Then, you execute psql <connection_string> from within the docker container
2

I had the same issue and search all over. Have tried a lot but finally I found a working solution. Seems like the problem is related to handling of 8.3 filenames. I followed the tip in: https://hub.alfresco.com/t5/alfresco-content-services-forum/solved-installation-error-on-windows-10-x64-registerservice-bat/td-p/209616

or go directly to

https://support.microsoft.com/en-gb/help/121007/how-to-disable-8.3-file-name-creation-on-ntfs-partitions

Compared to the guide my default registry key was 2 and not 0. Anyhow, changing it to 1 (+reboot) allowed the COMSPEC-test to pass. Seems to be a "installation script" vs "Win10" issue...

/Björn

1 Comment

As it’s currently written, your answer is unclear. Please edit to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center.
1

Hi i have faced the same issue but then i changed the environment variables of CompSpec to name: ComSpec and the path: C:\Windows\system32\cmd.exe and restarted my pc and it installed successfully. Hope it helps.

Comments

0

I had the same error like yesterday man and the answer above is pretty correct. I am just going to elaborate the procedure in clearor steps.

First, right-click on the Windows icon on your taskbar and select System.

In the Settings window, under Related Settings, click Advanced system settings.

On the Advanced tab, click Environment Variables.

Under System Variables click New to create a new environment variable. Name it ComSpec and set the path to point to C:\Windows\system32\cmd.exe

After creating the environment variable click Apply and then OK to have the change take effect.

Restart might be required.

Peace.

Comments

0

If the following error is displayed when running the installation.exe

Environment variables COMSPEC does not seem to point to The cmd.exe or there is a trailing semicolon present.

Most likely, the problem is with the antivirus and the command line is also blocked.

To solve this problem, follow the instructions below:

  1. Uninstall or disable the antivirus
  2. To restore CMD, enter the .\sfc /scannow command in the PowerShell as administer

Now that everything is back to normal, you can successfully run the installation.exe file. Note that your antivirus does not prevent the installation of postgresql again.

Comments

0

In Environment Variables use EDIT TEXT button carefully to remove the symbol' ; ' exactly and carefully. Some times it seems perfect but not get removed as expected. go to EDIT TEXT and Remove it perfectly.

1 Comment

As it’s currently written, your answer is unclear. Please edit to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center.

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.