Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PostgreSQL Installation Error: The environment variable COMSPEC does not seem to point to the cmd.exe

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

like image 645
Jun Kang Wong Avatar asked Mar 29 '26 02:03

Jun Kang Wong


1 Answers

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
like image 166
Wojciech Stańczewski Avatar answered Mar 31 '26 04:03

Wojciech Stańczewski



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!