4

I have to work with an ini file, but I need a value set in the file to be based on an environment variable. For example,

... [program] dir=%SystemDrive%\SomeFolder\ ...

In this case, SystemDrive is an environment variable on the machine. The software that reads this ini file is out of my control, but I can see from the error message I get that it read dir as %SystemDrive%\SomeFolder\, instead of the expanded version C:\SomeFolder\.

How do I (or is it possible to) get environment variables to expand when the ini file is read? I don't have access to the code of the program that reads the ini file. However, I'm hoping there is a proper syntax/technique for specifying an environment variable to be expanded.

1
  • 1
    Probably the only way to achieve this would be for you to write a program that replaced any such variables it found in the .ini file with their current values just before invoking the program that reads it.
    – martineau
    Jul 24, 2012 at 18:56

0

You must log in to answer this question.

Browse other questions tagged .