![]() |
problem with icons, CreateShortcut on 64-bit Windows and "C:\Program Files (x86)"
I've creating an NSIS package and noticed that when a program is installed to the legacy 32-bit folder on 64-bit Windows 7 Ultimate SP1, that "C:\Program Files (x86)" is being translated either by NSIS or Windows to the environmental variable "%ProgramFiles%" which resolves to the 64-bit version of Program Files. Where I'm running into a problem is with CreateShortcut and the custom icon setting. Here's my code for starters:
Quote:
What I also found is that in some cases the icon on the shortcuts will default back to the missing shortcut icon and you have to reset the icon manually on the shortcut for it to work again, which is how I discovered this problem. It does this every time after a reboot on the first shortcut in the code, the other ones are a bit different (URLs/Internet shortcuts) that don't seem to reset as often (so far). I'm still trying to fix this problem but thought I'd report about my findings, it's obviously a bug that needs fixing somewhere. NSIS 2.46... |
:eek: Removed public display of stupid...
|
These are shortcuts being installed to the Start Menu Programs folder, ala internal NSIS Constant $SMPROGRAMS. I also found that it makes no difference what InstallDir is, the user can change directories to C:\Program Files (x86) during the installation, or manually select C:\Program Files (x86) and it will convert the shortcut icon path to %ProgramFiles%. As I said I believe NSIS detects "C:\Program Files (x86)" in $INSTDIR and converts it to %ProgramFiles%... unless it is some internal calls of Windows doing it (which NSIS executes), which is definitely possible.
|
Edit, scratch part of what I said before.
This was my InstallDir: InstallDir "$PROGRAMFILES32\${APP_NAME}" I changed it to InstallDir "C:\PSOBB-installer\${APP_NAME}" Rebuild... Actually, I'll just post my entire script for you to test with some test files. I think the behavior I described with %ProgramFiles% variable only occurs if $PROGRAMFILES is initially used in InstallDir, this doesn't happen after changing InstallDir like I did above, and then manually select "C:\Program Files (x86)" as the installation location. Here's my script & test files to make it work if you wanna take a look and try it: http://strags.com/d2/nsis.zip |
Kodama,
PHP Code:
|
Did you check the Change Icon function to determine if the path was set correctly? Didn't work on Win7Ult x64.. BUT the icon does show up properly, at least right after install. Problem I have run into, is that it might default back to the broken shortcut icon after awhile, which shows up on the next screen.
http://strags.com/i/myapp.png http://strags.com/i/myapp.png http://strags.com/i/myapp2.png http://strags.com/i/myapp2.png |
If I go and put a copy of online.exe (for your example) in C:\Program Files\My App, it will find it without changing the shortcut. It won't work ever without being manually updated if it's in C:\Program Files (x86) under these exact circumstances. I used the same code as you...
|
AH! not I see the problem... I'm going to perform some tests to see what can be done about this.
|
Let me know what you find...
|
NSIS does not touch your strings, blame the windows shortcut API. At least for you main apps shortcut, try not setting the icon directly and just use "" as the icon path
Edit: Another option would be to remove the SLDF_HAS_EXP_ICON_SZ flag and datablock after the shortcut has been created: PHP Code:
|
As usual... Awesome work Anders :up:
I Wrapped your code up into a function/macro for easy implementation so I can add it to my own packages. I have been packaging for 64bit XP for some time but never noticed the issue. Worse yet no one has complained yet. :eek: PHP Code:
|
FYI: Wiki Article Created
|
That URL in the comment is broken. You should probably point to: http://forums.winamp.com/showthread.php?t=327806
|
Quote:
|
|
Internet shortcuts are even easier to tweak as they are just ini files.
Do somthing like this..code: PHP Code:
EDIT: Or just read the Wiki article Stu Posted.. :D |
Quote:
|
I found more information out about this issue. From the manual:
Quote:
So.. InstallDir "$PROGRAMFILES32\SCHTHACK PSOBB" has the problem. InstallDir "$PROGRAMFILES32\SCHTHACK PSOBB\" (disables behavior) doesn't have the problem. It seems to be something going wrong in this feature when it enumerates and appends "SCHTHACK PSOBB" to the directory selection. For example, a user will choose "C:\Program Files (x86)" as the directory rather than a sub directory, and NSIS will fill in the sub directory to match the last string of InstallDir after the last \, in this case "SCHTHACK PSOBB," making it auto to C:\Program Files (x86)\SCHTHACK PSOBB\. For some reason this breaks CreateShortcut icon association and perhaps other functions in NSIS. What it looks like is Windows is looking in the 64-bit Program Files directory for the icon when this function is enabled, even though the program is really in the 32-bit Program Files folder, which I think is the result of this features functionality mixing up the 64-bit and 32-bit Program Files folders or how it resolves them. |
Quote:
Try: PHP Code:
|
I'm going to have to confirm with Anders.
I modified the test script and the issue remains. Can you provide a script that shows the working vs non? PHP Code:
|
| All times are GMT. The time now is 17:23. |
Copyright © 1999 - 2010 Nullsoft. All Rights Reserved.