Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using %PROGRAMFILES(x86)% on Windows OS 32bit

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?

like image 519
sazr Avatar asked Jul 16 '13 23:07

sazr


People also ask

Does Windows 7 32-bit have Program Files x86?

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.

Are x86 programs 32-bit?

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.

Should I install to Program Files or Program Files x86?

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.


2 Answers

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".

like image 171
Roger Rowland Avatar answered Oct 16 '22 07:10

Roger Rowland


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"
}
like image 3
agabrys Avatar answered Oct 16 '22 07:10

agabrys