4
votes

One of my systems has a broken Delphi installation: it thinks BDSCOMMONDIR points to C:\Windows\system32\9.0 whereas on a functioning system, it points to C:\Users\Public\Documents\RAD Studio\9.0.

I'm probably the victim of corporate security madness, as I found out nobody can access the C:\Users\Public directory on the failing system anyway.

What I want is to move the content of the directory to a place where the developers can write, then globally (a subdirectory C:\ProgramData comes to mind) and globally set the BDSCOMMONDIR.

So: where does Delphi get the BDSCOMMONDIR value from?
How can I override it?

The major reason why it is holding me back is that I now get this on every compile/build I try:

[MakeDir Error] Unable to create directory "C:\Windows\system32\9.0\hpp\". Access to the path 'C:\Windows\system32\9.0\hpp\' is denied.
[MakeDir Error] Unable to create directory "C:\Windows\system32\9.0\Dcp". Access to the path 'C:\Windows\system32\9.0\Dcp' is denied.
[MakeDir Error] Unable to create directory "C:\Windows\system32\9.0\hpp". Access to the path 'C:\Windows\system32\9.0\hpp' is denied.
3
C:\ProgramData is absolutely the wrong place. It's set now to the proper place for documents shared among users ('C:\Users\Public\Documents\RAD Studio\9.0`), according to the Windows guidelines. If your corporate security is blocking access to that folder, you need new corporate security. ;-) - Ken White
I know it is the right place. But I also know how unforgiving security people can be. I once gave up after 8 weeks of bureaucrazy for getting a limited developer account (not even a local admin one) at one particular client. - Jeroen Wiert Pluimers
:-) One of the headaches we all have, I think. The point is, though, that you're going to have more trouble trying to use ProgramData, as you'll be fighting not only corporate security but Windows itself; AFAIK, normal (non-admin) users don't have write-access to that folder tree. - Ken White
The only place I know to find BDSCOMMONDIR defined is rsvars.bat file from bin subfolder, though not sure IDE uses it. - kludg
@Serg: See the answer posted below. The one in rsvars.bat is only used by Start->Embarcadero RAD Studio XE2->RAD Studio Command Prompt, which is only useful when using MSBuild to build from the command line. - Ken White

3 Answers

7
votes

You can go to

Tools|Options|Environment Options|Environmental Variables

double click on

BDSCOMMONDIR

and set it to whatever you want.

Also get a look at Where are environment variables stored in registry?

1
votes

I now had access to a system with Delphi 2007 showing similar symptoms for which I used RegAlyzer to verify.

By default, Delphi 2007 uses the SYSTEM setting of the environment variable from the registry:

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment

It never gets the value from the USER environment variable key in the registry:

HKEY_CURRENT_USER\Environment

An override is stored by Delphi 2007 (which is BDS version 5.0) under this key:

HKEY_CURRENT_USER\Software\Borland\BDS\5.0\Environment Variables

All three keys store regular REG_SZ name/value pairs (where name is BDSCOMMONDIR).

My guess (I hope to eventually verify this) is that newer Delphi versions have similar behaviour because of backward compatibility.

1
votes

Question is rather old but here is the correct answer for future readers: RAD Studio/Delphi doesn't store the BDSCOMMONDIR (and others) in the registry but you can find it in a file named rsvars.bat, inside the \bin folder.

Example extracted from my Delphi 10.3 Rio installation:

@SET BDS=C:\Delphi\Embarcadero\Studio\20.0
@SET BDSINCLUDE=C:\Delphi\Embarcadero\Studio\20.0\include
@SET BDSCOMMONDIR=C:\Users\Public\Documents\Embarcadero\Studio\20.0

unless you have manually overridden it through Environment Variables option. In that case, it will be under the registry key:

HKEY_CURRENT_USER\Software\Embarcadero\BDS<VERSION NUMBER>\Environment Variables