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

Viewed 2922

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

3 Answers

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.

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

Related