From a command prompt, I get the following:

>echo %ProgramFiles%
C:Program Files

However, some applications (PHP in this instance, though I’ve seen the same behavior from within Apache’s httpd.conf), it is:

>php -r "echo $_ENV['ProgramFiles'];"
C:Program Files (x86)

Why is this?

Background: I’m developing scripts that are agnostic of the host OS being 32bit or 64bit, and for configuration files this works great. On a 32bit system, %ProgramFiles% is “C:Program Files”, and on a 64bit system that same %ProgramFiles% seemingly returns C:Program Files (x86). I’m just curious why the same doesn’t hold true when I try it from the Windows command prompt (or in the explorer bar, etc.). Is there a 64bit command prompt or something?

Leave a Reply

Your email address will not be published. Required fields are marked *