Go Back   Winamp & Shoutcast Forums > Developer Center > NSIS Discussion

Reply
Thread Tools Search this Thread Display Modes
Old 25th February 2011, 08:28   #1
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,442
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:
CreateShortcut "$temp\test.lnk" "c:\windows\system32\calc.exe" "" "c:\windows\explorer.exe" 1

System
::Call 'OLE32::CoCreateInstance(g "{00021401-0000-0000-c000-000000000046}",i 0,i 1,g "{000214ee-0000-0000-c000-000000000046}",*i.r1)i'
${If} $<> 0
    System
::Call '$1->0(g "{0000010b-0000-0000-C000-000000000046}",*i.r2)'
    
${If} $<> 0
        System
::Call '$2->5(w "$temp\test.lnk",i 2)i.r0'
        
${If} $0
            System
::Call '$1->0(g "{45e2b4ae-b1c3-11d0-b92f-00a0c90312e1}",*i.r3)i.r0'
            
${If} $<> 0
                System
::Call '$3->5(i 0xA0000007)i.r0'
                
System::Call '$3->6(*i.r4)i.r0'
                
${If} $
                    IntOp 
$$0xffffBFFF
                    System
::Call '$3->7(ir4)i.r0'
                    
${If} $
                        System
::Call '$2->6(i0,i0)'
                    
${EndIf}
                ${EndIf}
                
System::Call $3->2()
            ${EndIf}
        ${EndIf}
        
System::Call $2->2()
    ${EndIf}
    
System::Call $1->2()
${EndIf} 
After I do this, (on XP) the change shortcut icon dialog displays c:\windows\explorer.exe and not %SystemRoot%\explorer.exe

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Old 25th February 2011, 19:24   #2
o___O
Junior Member
 
Join Date: Mar 2002
Posts: 27
Quote:
Originally Posted by Anders View Post
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:

After I do this, (on XP) the change shortcut icon dialog displays c:\windows\explorer.exe and not %SystemRoot%\explorer.exe
Neither of these are suitable alternatives, though. The shortcuts I want to specify the icon on are Internet links, the default icon is just ugly and doesn't go with the program. Secondly, NSIS must be involved in this process somehow, because if InstallDir is set to "C:\${APP_NAME}" by default rather than "$PROGRAMFILES32\${APP_NAME}" - one can manually select the "C:\Program Files (x86)" folder during installation and not have this problem (shortcut icon path is correct, icons never vanish). I think the problem has to do with how NSIS is resolving $PROGRAMFILES or handling these Constants and the environmental variables internally (might be specific to InstallDir directive or when or how these variables are used)... Give it another look.
o___O is offline   Reply With Quote
Old 25th February 2011, 21:32   #3
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,442
Quote:
Originally Posted by o___O View Post
I think the problem has to do with how NSIS is resolving $PROGRAMFILES or handling these Constants and the environmental variables internally (might be specific to InstallDir directive or when or how these variables are used)... Give it another look.
InstallDir does not do anything special, $PROGRAMFILES is resolved using a documented shell function the registry and nsis itself does not use environment variables IIRC.

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Old 2nd March 2011, 09:12   #4
o___O
Junior Member
 
Join Date: Mar 2002
Posts: 27
I found more information out about this issue. From the manual:

Quote:
4.8.1.21 InstallDir
definstdir
Sets the default installation directory. See the variables section for variables that can be used to make this string (especially $PROGRAMFILES). Note that the part of this string following the last \ will be used if the user selects 'browse', and may be appended back on to the string at install time (to disable this, end the directory with a \ (which will require the entire parameter to be enclosed with quotes). If this doesn't make any sense, play around with the browse button a bit.
So the problem is with this behavior in NSIS when InstallDir doesn't end with a \. Disable this feature and the icons and shortcuts are fine.

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.
o___O is offline   Reply With Quote
Old 2nd March 2011, 12:11   #5
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,442
Quote:
Originally Posted by o___O View Post
making it auto to C:\Program Files (x86)\SCHTHACK PSOBB\.
Are you sure about this? $instdir will normally strip off the \ at the end.

Try:
PHP Code:
strcpy $instdir "c:\temp\"
MessageBox mb_ok 
$instdir 

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Old 2nd March 2011, 13:59   #6
Zinthose
Senior Member
 
Join Date: May 2009
Posts: 152
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:
!define APP_NAME "My App"
OutFile lnkTest.exe
ShowInstDetails show

InstallDir 
"$PROGRAMFILES32\${APP_NAME}\"

Page directory
Page instfiles

Section
    SetOutPath "
$INSTDIR\"
    File /oname=online.exe "
C:\WINDOWS\NOTEPAD.EXE"
    
    CreateDirectory "
$SMPROGRAMS\${APP_NAME}"
    CreateShortcut "
$SMPROGRAMS\${APP_NAME}\${APP_NAME}.lnk" "$INSTDIR\online.exe" "" "$INSTDIR\online.exe" "" "" "" "Launches PSOBB"
SectionEnd 
Zinthose is offline   Reply With Quote
Reply
Go Back   Winamp & Shoutcast Forums > Developer Center > NSIS Discussion

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump