Windows – How to write the path of a 32 bit executable in the Windows’ Program Files folder regardless of the Windows version

windows

I want to write something like

%ProgramFiles(x86)%\someprogram\someprogram.exe

That would work in both Windows 32 and 64-bit versions

But:

  1. %ProgramFiles% points to the 32 bit program files folder only in 32bit Windows
  2. %ProgramFiles(x86)% points to the 32 bit program files folder only in 64bit Windows (it doesn't exist in 32-bit Windows)

Is there any Windows Environment variable that always point to the 32 bit program files folder, regardless of the Windows version?

Best Answer

You can always add %ProgramFiles(x86)% to the 32bit Windows platforms. You can use a simple command line to add it:

Set ProgramFiles(x86) = "C:\Program Files"

Then you have consistency across platforms.

Edit:

Since you told me what it is for, I would do something like this for your instructions:

1 - Change to the directory for the program. 

2 - open a command prompt 

3a - type "cd %programfiles(x86)%" 

3b - If  you receive the error "The system cannot find the path specified", 
     go to step 3c.  Otherwise go to 4. 

3c - type "cd %programfiles%" 

4 - Other stuff