Something is wrong with Delphi XE2 processing with overridden user environment variables. Take an example application:
program Project1; {$APPTYPE CONSOLE} uses System.SysUtils; begin Writeln(GetEnvironmentVariable('PATH')); Readln; end.
This makes the path fine when exiting the debugger or when there is no overridden user environment variable. But as soon as you enter the environment variable in Run-> Parameters-> Environment Block, it displays an empty string.
A possible workaround is to override the required variable, in this case "PATH". The program can then output (and possibly use) the correct path. Obviously, this is a fairly limited workaround. When you use user redefinition, it is not only "PATH" that you lose. The FI example program still will not be able to output "APPDATA".
Previous versions of Delphi do not seem to have this problem. There QC report: Enable system variables no longer works , which is closed as "fixed" in assembly 17.0.4625.53395.
source share