I have the following NSIS code
Function CreateDesktopSC
;Creates Desktop Shortcut
SetShellVarContext current
SetOutPath "$DOCUMENTS\Foo\"
SetShellVarContext all
detailprint "Icon path: $INSTDIR\Bar\icon.ico"
CreateShortCut "$DESKTOP\${productName}.lnk" "$INSTDIR\Bar\binary.exe" "" "$INSTDIR\Bar\icon.ico" 0
FunctionEnd
The install log shows the following (from the detailprint command) Icon path: C:\Program Files (x86)\Bar\icon.ico
The shortcut is created, but with the icon from the executable.
If I open the lnk file or right click the shortcut and click "Change Icon ...", I get the error "Windows can't find the file %ProgramFiles%\Bar\icon.ico."
If I browse to %ProgramFiles%, it takes me to c:\Program Files, not the x86 version as shown in the detailsprint command. The icon file exists, but in the x86 folder.
It appears that either NSIS or windows is replacing "C:\Program Files (x86)\" with "%ProgramFiles%", which doesn't point to the x86 version.
The actual path to the executable is correct, it's only the icon link which is incorrect.
Any ideas?