4

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.
Jeroen Wiert Pluimers
  • 23,965
  • 9
  • 74
  • 154
  • `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 Sep 05 '12 at 17:01
  • 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 Sep 05 '12 at 17:10
  • :-) 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 Sep 05 '12 at 17:22
  • The odd thing: I closed all applications, restarted Delphi, and now everything works dandy. There are much more directories under `C:\Users\Public` now (even from other applications) *and* I have write access. Must have been one of those nice Folder Redirection Policies or? – Jeroen Wiert Pluimers Sep 05 '12 at 17:27
  • 1
    The only place I know to find `BDSCOMMONDIR` defined is `rsvars.bat` file from `bin` subfolder, though not sure IDE uses it. – kludg Sep 05 '12 at 17:33
  • 1
    @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 Sep 05 '12 at 17:58

3 Answers3

7

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?

Community
  • 1
  • 1
RBA
  • 12,337
  • 16
  • 79
  • 126
  • `BDSCOMMONDIR` is not as an environment variable in the registry, and it still is assigned a value when I look in the IDE. Do you know if the your suggestion is persistent? – Jeroen Wiert Pluimers Sep 05 '12 at 16:56
  • In all the cases I have changed it, it worked. I can not assure you that this change will work 100%. Guys from Embarcadero have not published from where the BDSCOMMONDIR is coming. Maybe I am wrong on this. If it is true I will delete the answer. – RBA Sep 05 '12 at 17:01
  • In my XE2 installation, I have a BDSCOMMONDIR override in the IDE's Environment Options, seems to work ok for me. – Remy Lebeau Sep 05 '12 at 17:18
  • Even though my problem resolved itself (don't you love that), your option seems the only workaround. Hence accepted. – Jeroen Wiert Pluimers Sep 05 '12 at 17:32
  • 1
    There is definitely some hairy badness going on here. (IDE Bug?) One place where I saw this bug happen, it was a Windows Server with Terminal Services, and there was some EXTRA strange IDE bugs with BDSCOMMONDIR going snaky. – Warren P Sep 05 '12 at 19:59
1

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.

Jeroen Wiert Pluimers
  • 23,965
  • 9
  • 74
  • 154
1

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

Alexandre M
  • 1,146
  • 12
  • 23