7

I can get %ProgramFiles% in Ant with ${env.PROGRAMFILES}. But I can't figure out how to get %ProgramFiles(x86)%.

Mads Hansen
  • 63,927
  • 12
  • 112
  • 147
Jerry
  • 669
  • 8
  • 17

2 Answers2

8

Use ${env.ProgramFiles(x86)}. The variable is case-sensitive in a way that is inconsistent with env.PROGRAMFILES.

[echo] env.ProgramFiles(x86) == C:\Program Files (x86)
[echo] env.PROGRAMFILES(x86) == ${env.PROGRAMFILES(x86)}
[echo] env.ProgramFiles      == ${env.ProgramFiles}
[echo] env.PROGRAMFILES      == C:\Program Files
Jerry
  • 669
  • 8
  • 17
  • For me the two variable cases where not inconsistent: they are env.ProgramFiles and env.ProgramFiles(x86). Maybe something changed in a newer ant? I have ant 1.9.4. – Vlad Nov 11 '14 at 17:51
2

Have you tried ${env.PROGRAMFILES(x86)} ? (See how to get program files x86 env variable?)

Apologies, I don't have a windows machine to test this one.

If this doesn't work I'd suggest adding the following property task in your build:

<property environment="env"/>

And run ANT in debug mode to see the values set:

 ant -d 
Community
  • 1
  • 1
Mark O'Connor
  • 76,015
  • 10
  • 139
  • 185
  • Thanks for the suggestion, Mark. That syntax doesn't work; however, in the course of mis-typing it, I found that ${env.ProgramFiles(x86)} works. It's an odd thing -- ${env.PROGRAMFILES} works but ${env.ProgramFiles} does not. So there's some inconsistency in the syntax here. Thanks for getting me to the solution! – Jerry Nov 19 '12 at 20:29