"Program Files" paths become Program Files (x86)

English support forum

Moderators: white, Hacker, petermad, Stefan2

Post Reply
KilliK
Junior Member
Junior Member
Posts: 4
Joined: 2016-03-11, 01:27 UTC

"Program Files" paths become Program Files (x86)

Post by *KilliK »

Hello.

I have created a small autohotkey script to create custom shortcuts from exe files when I press its button in Total Commander. The script works fine but when I use it on files which exist inside the Program Files folder, the path in the resulted shortcuts becomes Program Files (x86) and the shortcut doesnt work. Then I have to manually change the path of the shortcut to its original destination in order to make it work.

This happens only with the exe files in the Program Files folder.
It doesnt happen if I run the script in that folder but outside TC. The paths will remain the same.
The problem also happens with the Nircmd utility which can create shortcuts.
This doesnt happen if I create the shortcut by using TC's right click context menu.
This doesnt happen with the exe files in Program Files (x86)

I did some searching and from what I understand, this is a feature from Windows, it redirects the Program Files path to Program Files (x86).

Is there a way I can avoid this, so that my custom shortcuts will point to the original Program Files path?

My OS is Windows 10 Pro x64
I am using Total Commander 9.0a 32bit
Last edited by KilliK on 2017-10-21, 22:41 UTC, edited 5 times in total.
User avatar
sqa_wizard
Power Member
Power Member
Posts: 3854
Joined: 2003-02-06, 11:41 UTC
Location: Germany

Post by *sqa_wizard »

Redirection mostly happens when using an environment variable like %ProgramFiles%

Using TC-32bit uses the 32-bit set of variables

Code: Select all

ProgramFiles=C:\Program Files (x86)
ProgramFiles(x86)=C:\Program Files (x86)
ProgramW6432=C:\Program Files
Using TC-64bit uses the 64-bit set of variables

Code: Select all

ProgramFiles=C:\Program Files
ProgramFiles(x86)=C:\Program Files (x86)
ProgramW6432=C:\Program Files
You may see that %ProgramFiles% differs ...

Use the exact variable %ProgramW6432% if you really want the file in 64-bit path.
#5767 Personal license
KilliK
Junior Member
Junior Member
Posts: 4
Joined: 2016-03-11, 01:27 UTC

Post by *KilliK »

Thank you for your help, but it still doesnt work.

I replaced the target path of a shortcut from:
C:\Program Files\Apone\Apone.exe
to
%ProgramW6432%\Apone\Apone.exe

but I am getting a "Search path not found!" error when I run it.

The same shortcut works flawlessly if I run it from Windows's file explorer.

What am I doing wrong? :cry:
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 48021
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Post by *ghisler(Author) »

Try putting the name in double quotes, otherwise Windows will split the path into multiple parameters (separated at the spaces).
Author of Total Commander
https://www.ghisler.com
KilliK
Junior Member
Junior Member
Posts: 4
Joined: 2016-03-11, 01:27 UTC

Post by *KilliK »

Thank you for your reply.

I followed your suggestion, but it still doesnt work if I run it from inside TC. The shortcut's icon is missing and I am getting a file not found error. There is no problem if I run it from Windows' file explorer.

BUT, here is the weird thing.
If I right click the created shortcut from inside TC, open up its properties tab and then immediately press ok, then the shortcut is fixed. The shortcut appears and the shortcut works as intended!!

What causes this?
it's as if TC needs somehow to first "see" the target path of the shortcut before it starts redirecting it.
User avatar
Dalai
Power Member
Power Member
Posts: 9364
Joined: 2005-01-28, 22:17 UTC
Location: Meiningen (Südthüringen)

Post by *Dalai »

Thank MS for this crap. It's the stupid IShellLink interface that automatically resolves link targets - the real path to CSIDLs (known folder paths) and back. Example you can try for yourself: Create a shortcut with e.g. C:\Program Files\Internet Explorer\iexplore.exe from a 64 bit program (Explorer, TC 64 bit). Then start TC 32 bit and navigate to the directory where the link is located. Take a look at the link's properties again: the link target will say C:\Program Files (x86)\Internet Explorer\iexplore.exe. If you don't change the link target, you can switch back to a 64 bit program and look at the link target again: C:\Program Files\Internet Explorer\iexplore.exe.

This is "normal" Windows Shell behavior which resolves the link target based on the current environment. This is done when you look at the link's properties and when the link is executed. There's nothing you can do about it but to use something different than shortcuts (e.g. a batch script).

Regards
Dalai
#101164 Personal licence
Ryzen 5 2600, 16 GiB RAM, ASUS Prime X370-A, Win7 x64

Plugins: Services2, Startups, CertificateInfo, SignatureInfo, LineBreakInfo - Download-Mirror
KilliK
Junior Member
Junior Member
Posts: 4
Joined: 2016-03-11, 01:27 UTC

Post by *KilliK »

Thank you for the explanation, Dalai.
yeah, that whole path redirection compatibility feature is a pain in the ###.

Luckily I found a batch which creates shortcuts with the Programs File path intact and now I am using that from TC's button bar.

thanks for all the help.
Post Reply