Page 1 of 1

Parsing of %ProgramFiles% under 64-bit Windows

Posted: 27 Sep 2009 13:04
by nas8e9
I'm not entirely sure if this is a bug or a feature request, but here goes: when parsing %ProgramFiles% under 64-bit Windows, XYplorer returns the value of %ProgramFiles(x86)% instead of %ProgramFiles%. Under 64-bit Windows, 32-bit apps get installed in %ProgramFiles(x86)% and 64-bit apps get installed in %ProgramFiles%. When calling a 64-bit program (installed in %ProgramFiles%) from a script, using %ProgramFiles% doesn't work because it returns %ProgramFiles(x86)%.

By way of an example, when calling TeraCopy.exe installed in C:\Program Files\TeraCopy (i.e. %ProgramFiles%\TeraCopy), calling %ProgramFiles%\TeraCopy\TeraCopy.exe returns C:\Program Files (x86)\TeraCopy\TeraCopy.exe which is incorrect. I suspect this has to do with 64-bit Windows "lying" to a 32-bit app like XYplorer; also, the problem can be easily circumvented by hardcoding C:\Program Files\ instead of %ProgramFiles% since Vista and Windows 7 always assign C: to the Windows partition. Nevertheless, with 64-bit Windows and apps becoming more prevalent, it's an issue that may crop up more often.

OS: Windows 7 x64 RTM
XYplorer 8.40.0112 beta.

Re: Parsing of %ProgramFiles% under 64-bit Windows

Posted: 28 Sep 2009 03:19
by mwb1100
By default on a 64-bit windows systems the following 'program files' related environment variables are set (I imagine a registry setting or something can change this):
  • %ProgramFiles%: for 32-bit processes is set to "C:\Program Files (x86)", for 64-bit processes is set to "C:\Program Files"
  • %ProgramFiles(x86)%: set to "C:\Program Files (x86)"
  • %ProgramW6432%: set to "C:\Program Files"
(Note the above directory names are localized)


XY is a 32-bit program, so the %ProgramFiles% variable points to the "C:\Program Files (x86)" directory. I'm not sure if XY can do anything reasonable here to solve your problem, because some programs are in the C:\Program Files" directory and others are in "C:\Program Files (x86)". It might be best to have the shortcut or script use the %ProgramW6432% environment variable for programs in "C:\Program Files".

Re: Parsing of %ProgramFiles% under 64-bit Windows

Posted: 28 Sep 2009 08:00
by nas8e9
mwb1100 wrote:By default on a 64-bit windows systems the following 'program files' related environment variables are set (I imagine a registry setting or something can change this):
  • %ProgramFiles%: for 32-bit processes is set to "C:\Program Files (x86)", for 64-bit processes is set to "C:\Program Files"
  • %ProgramFiles(x86)%: set to "C:\Program Files (x86)"
  • %ProgramW6432%: set to "C:\Program Files"
(Note the above directory names are localized)


XY is a 32-bit program, so the %ProgramFiles% variable points to the "C:\Program Files (x86)" directory. I'm not sure if XY can do anything reasonable here to solve your problem, because some programs are in the C:\Program Files" directory and others are in "C:\Program Files (x86)". It might be best to have the shortcut or script use the %ProgramW6432% environment variable for programs in "C:\Program Files".
My main concern was whether this was something in XYplorer or a peculiarity of 64-bit Windows. There are indeed workarounds possible in scripting; thank you for confirming that this is a Windows thing.