# Problem with project variables in batch files

**URL:** <https://www.finalbuilder.com/forums/t/problem-with-project-variables-in-batch-files/3268>\
**Category:** Bugs\
**Created:** [August 11, 2010, 1:21am UTC](https://www.finalbuilder.com/forums/t/problem-with-project-variables-in-batch-files/3268 "2010-08-11T01:21:09Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![pspain](https://www.finalbuilder.com/forums/letter_avatar_proxy/v4/letter/p/bbe5ce/32.png) [@pspain](https://www.finalbuilder.com/forums/u/pspain)\
**Post date:** [August 11, 2010, 1:21am UTC](https://www.finalbuilder.com/forums/t/problem-with-project-variables-in-batch-files/3268/1 "2010-08-11T01:21:09Z")

</div>

&nbsp;FB7.0.0.515 / FB6.3.0.2026 / Windows XP &nbsp;Professional SP3

&nbsp;

Hi there!

&nbsp;

I have attached an example project enviroDemo.zip to demonstrate the issue.

&nbsp;

It appears Project Variables with attributes "Make Env" and "Is Macro" - DIR\_RESTORED\_REPOSITORY here - may not be evaluated properly when accessed from the environment in a subsequent batch file, enviroDemo.bat.&nbsp;

&nbsp;

The batch file echoes the variable DIR\_RESTORED\_REPOSITORY as:

&nbsp;

1) extracted from the batch file's environment

&nbsp;

2) &nbsp;passed in via a command-line argument , %1, to the batch file

&nbsp;

DIR\_RESTORED\_REPOSITORY (=%DIR\_RESTORED ROOT%\Repository) relies on another project variable, DIR\_RESTORED ROOT, that is loaded from an INI file as the first action of the script.

&nbsp;

Case 2 above is the expected value. It appears that Case 1 is the value of DIR\_RESTORED\_REPOSITORY as evaluated \_before\_ the script begins, i.e. before the value of DIR\_RESTORED ROOT is read from the INI file.

&nbsp;

Perhaps a variable with both attributes "Make Env" and "Is Macro" is only injected into the environment at the start of a script, &nbsp;rather than at each macro evaluation, or before each action?

&nbsp;

I hope this is clear enough! Thanks, Paul.

---

<div class="post-metadata">

**Author:** ![Vincent](https://www.finalbuilder.com/forums/user_avatar/www.finalbuilder.com/vincent/32/938_2.png) [@Vincent](https://www.finalbuilder.com/forums/u/Vincent)\
**Post date:** [August 11, 2010, 2:19am UTC](https://www.finalbuilder.com/forums/t/problem-with-project-variables-in-batch-files/3268/2 "2010-08-11T02:19:14Z")

</div>

Hi Paul   
  
 The reality is that we should have not allowed both options to be enabled together. Variables set to “Make Env” only set the environment variable when they are themselves set, and in the case of Macro variables, that only happens when the variable is reset at the start of the build. Setting them again at the start of every action is not practical, and would slow down some builds (we see users project files with hundreds of variables!).   
  
 What I have done for the next build, is that every time a “macro & env” variable is evaluated, it will set the environment variable. That still doesn’t help your example project, however using this scenario, I added a log variables action before the run dos command, and it then worked as desired. A bit of a kludge I guess, but usable none the less.   
  
 We’ll be posting a new build shortly, just testing some other fixes.
