What happens when I use the environment variable %PROGRAMFILES(x86)%
on a Windows OS that is 32bit (ie, older versions of Windows such as Windows XP, Vista)?
I am hoping that it will simply resolve to: C:/Program Files
. Will this occur?
The 32-bit version automatically installs to C:\Program Files (x86), and the 64-bit version automatically installs to the C:\Program Files. If Windows used a single folder, the application's developer would have to have the 64-bit folder install to a different folder to keep them separate.
Starting with Windows Vista, the 64-bit versions of Windows have two Program Files folders. The regular Program Files folder holds 64-bit applications, while "Program Files (x86)" is used for 32-bit applications.
It doesn't normally matter whether a program's files are stored in Program Files or Program Files (x86). Windows automatically installs programs to the correct folder, so you don't have to think about it. Programs appear in the Start menu and function normally, no matter where they're installed.
According to this the environment variable %PROGRAMFILES(x86)%
is only available on 64-bit systems.
However, if you are on a 64-bit system and use %PROGRAMFILES%
, the result you get depend on whether the process requesting the environment variable is 32-bit or 64-bit.
So from a 64-bit process on a 64-bit system you would get C:\Program Files
, from a 32-bit process on a 64-bit system you would get C:\Program Files (x86)
, and from a 32-bit process on a 32-bit system you would get C:\Program Files
.
If this doesn't help, perhaps you can comment or edit your original question to make it specific what you are trying to do. As it currently stands, the answer to your question is "No".
Keith Hill answered this question here, summary:
${env:ProgramFiles(x86)}
is not defined on a 32-bit machine
If you always want to put/get data to/from x86 directory, then you can use this code to determine file paths:
$file = "\file"
if ("${Env:ProgramFiles(x86)}")
{
$fullPath = "${Env:ProgramFiles(x86)}\$file"
}
else
{
$fullPath = "${Env:ProgramFiles}\$file"
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With