%programfiles% on a 64bit system

Things you’d like to miss in the future...
Forum rules
You might want to read this if you're looking for priority service

:info: Please Include The Following Information
1) Your XYplorer Version (e.g., v28.00.0801)
2) Your Windows Version (e.g., Win 11)
3) Your Screen Scaling Percentage (e.g., 125%).

:info: Use Your Profile Or Signature
We strongly recommend adding your Windows Version and Screen Scaling Percentage to the Location field in your Profile or to your Signature. That way, you only have to type them once, and we won't have to search for that vital information.

:info: How To Attach Images
When attaching an Image, please use the Attachment tab at the bottom of your post and click "Add files".
Post Reply
highend
Posts: 15016
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

%programfiles% on a 64bit system

Post by highend »

Hi,

msg %programfiles%;
shows "C:\Program Files (x86)"

on a 64bit OS (Windows Server 2012 R2).
Which is apparently wrong.

Can you resolve that to the correct folder (C:\Program Files) although XY is only a 32bit application?

And a feature wish as well:
Help file - Advanced topics - Variables
These are the valid environment variables in XYplorer:
%programfiles(x86)%

is missing in the list. One could assume that it's not a valid variable.
Can you add it (if it is)?

Thx,
Highend
One of my scripts helped you out? Please donate via Paypal

admin
Site Admin
Posts: 67299
Joined: 22 May 2004 16:48
Location: Win8.1, Win10, Win11, all @100%
Contact:

Re: %programfiles% on a 64bit system

Post by admin »

Check out this:

%ProgramFiles% = C:\Program Files (x86)
%ProgramFiles(x86)% = C:\Program Files (x86)
%ProgramW6432% = C:\Program Files

highend
Posts: 15016
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: %programfiles% on a 64bit system

Post by highend »

Yeah, but the ones you've posted are (partially) wrong.

Correct variable resolving looks like this:

64bit OS:
%ProgramFiles% = C:\Program Files
%ProgramFiles(x86)% = C:\Program Files (x86)
%ProgramW6432% = C:\Program Files

32bit OS:
%ProgramFiles% = C:\Program Files
%ProgramFiles(x86)% = DOES NOT EXIST (by default)
%ProgramW6432% = DOES NOT EXIST (by default)
One of my scripts helped you out? Please donate via Paypal

admin
Site Admin
Posts: 67299
Joined: 22 May 2004 16:48
Location: Win8.1, Win10, Win11, all @100%
Contact:

Re: %programfiles% on a 64bit system

Post by admin »

No, this is by design. %ProgramFiles% is sensitive to the bitness of the calling process:

32-bit process: %ProgramFiles% = C:\Program Files (x86)
64-bit process: %ProgramFiles% = C:\Program Files

It's the way WOW64 is designed. This is not my idea. These variables and their values are owned by Windows.

highend
Posts: 15016
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: %programfiles% on a 64bit system

Post by highend »

Ok, I wondered in the first post if it's related to XY beeing only a 32bit app.

Can we have another _internal_ XY var that handles %programfiles% depending on os bitness? :)
One of my scripts helped you out? Please donate via Paypal

binocular222
Posts: 1424
Joined: 04 Nov 2008 05:35
Location: Win11, Win10, 100% Scaling

Re: %programfiles% on a 64bit system

Post by binocular222 »

highend wrote:Can we have another _internal_ XY var that handles %programfiles% depending on os bitness? :)
We already have %osbitness%, just do a bit if-else with that variable is ok
I'm a casual coder using AHK language. All of my xys scripts:
http://www.xyplorer.com/xyfc/viewtopic. ... 243#p82488

highend
Posts: 15016
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: %programfiles% on a 64bit system

Post by highend »

I'm using

Code: Select all

$osProgramFiles = (%osbitness% == 64) ? "%ProgramW6432%" : "%Programfiles%";
as a workaround but an internal variable would feel more "native" ;)

Like %osprogramfiles% could automatically resolve to the correct program files dir...
One of my scripts helped you out? Please donate via Paypal

Marco
Posts: 2354
Joined: 27 Jun 2011 15:20

Re: %programfiles% on a 64bit system

Post by Marco »

Maybe I'm still sleepy, but I don't understand exactly what you want to achieve, highend.
Tag Backup - SimpleUpdater - XYplorer Messenger - The Unofficial XYplorer Archive - Everything in XYplorer
Don sees all [cit. from viewtopic.php?p=124094#p124094]

binocular222
Posts: 1424
Joined: 04 Nov 2008 05:35
Location: Win11, Win10, 100% Scaling

Re: %programfiles% on a 64bit system

Post by binocular222 »

he means:
%programfile% resolve relative to process's bitness (XY is always x32)
%osprogramfile% resolve relative to OS's bitness
I'm a casual coder using AHK language. All of my xys scripts:
http://www.xyplorer.com/xyfc/viewtopic. ... 243#p82488

Post Reply