Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|improve this question
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 '12 at 18:56

You must log in to answer this question.

Browse other questions tagged .