Sunday, March 18, 2012

Unable to write inside TEMP environment variable path

I stumbled upon this beautiful error when trying to re-install my PostgreSQL 9.1.3 server: Unable to write inside TEMP environment variable path.

After some research and trial-and-terror [sic], I came to the conclusion that the essence of the problem had been a tiny change I made to my system's file associations (via Notepad++).

Here's how I solved it and how you can do it too:

I first made some research in the existing community but the solutions I found did not apply to me (I provide some links at the end of the page to these solutions):
  • I checked if it was related to the option "Use temporary folders per session" in the "Remote Desktop Session Host Configuration";
  • I checked the status of "Windows Script Host Settings" (whost.exe);
  • I completely skipped antivirus-related stuff as I don't have any antivirus.

So, to understand why this error was happening, I went to my TEMP folder and read the log from the PostgreSQL installer:


Which mentioned an interesting detail:
  • Input Error: There is no script engine for file extension ".vbs".
So, I picked up another file from the TEMP folder, the actual script used by the installer:


And tried to run it through the console using cscript:

Input Error: There is no script engine for file extension ".vbs".

The same!
I researched a bit more and discovered that the type of file associated with the vbs extension had been changed. In my case, by Notepad++. After I installed Notepad++, I associated some file extensions with it (including vbs), thus causing problems when detecting the type of the script (which shouldn't happen).

Fixing it

Run the almighty regedit, navigate to HKEY_CLASSES_ROOT\.vbs and change the (Default) key back to the string VBSFile. In my case it had been previously altered to Notepad++_file.

How the registry entries looked like before

How the registry entries look when fixed

Then, restart PostgreSQL's installer and everything should go fine.

This is just a possible pair of cause-solution. Other solutions can be reached via some of the links below, don't forget to check them if my post doesn't apply to your issue.

Useful links:
Input Error: There is no script engine for file extension “.vbs”.
Running VBScript and JScript files from the Command Shell
Temporary directory environment variable in Windows Server 2008
Running & Installing PostgreSQL On Native Windows
Collect the installer log file (PostgreSQL)
Unable to write inside TEMP environment path