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?

link|improve this question

feedback

1 Answer

up vote 1 down vote accepted

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
link|improve this answer
You're right, but I need a solution that would work out of the box. – Jader Dias Sep 1 '10 at 13:25
1  
What are you using this for? I ask because if you are writing a script or installer, or a batch file, it is trivial to add this variable: IF %ProgramFiles(x86) == "" SET ProgramFiles(x86) = "C:\Program Files" – JNK Sep 1 '10 at 13:29
I'm putting this path in the web as instructions to a not-so-smart audience – Jader Dias Sep 1 '10 at 13:48
In that case, I would say make it a 2-part step. See edit to my answer. – JNK Sep 1 '10 at 13:52
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.