No announcement yet.

Shortcut icon not displayed

This topic is closed.
  • Filter
  • Time
  • Show
Clear All
new posts

  • Shortcut icon not displayed

    I have NSIS 2.50.

    I am learning about NSIS and I have a working installation script. However, I cannot get the icon to display on the desktop or in the start menu. I have a 64-bit Win7, but it is a 32-bit application (a .jar). I can change the icon to the correct one in Properties and before I do that, I see the error about not being able to find the .ico file in %Program Files%.

    I have searched far and wide and tried a lot of things. I have tried
    InstallDirRegKey HKEY_LOCAL_MACHINE "SOFTWARE\Microsoft\Windows\CurrentVersion" "ProgramFiles (x86)"

    But that didn't help. I have tried adding more backslashes to my paths, but it has made no difference. I have tried using $PROGRAMFILES32 instead of $PROGRAMFILES, but that didn't help.

    I tried reading the program files registry key and using that to set my install directory, but it didn't help.

    Here are the relevant lines from my script:

    InstallDir "$PROGRAMFILES\ObitEdit"
    CreateShortCut "$SMPROGRAMS\ObitEdit\ObitEdit.lnk" "$INSTDIR\ObitEdit.jar" "" "$INSTDIR\odt_log.ico"
    CreateShortCut "$DESKTOP\ObitEdit.lnk" "$INSTDIR\ObitEdit.jar" "" "$INSTDIR\odt_log.ico"

    My icon is 48x48. I've tried adding a zero at the end of the CreateShortCut line, and that didn't help.

    Everything works great, there's just no picture showing. I've read enough to understand that it has to do with how $PROGRAMFILES is handled once it gets to Windows. I see people find some way to get around it successfully, but nothing has worked for me.

    I'm hopeful someone out there can see what's wrong.

  • #2
    Next time please try searching the forum before asking, this has been asked several times already. See etc. If you already found one of those threads then you should have posted there.
    IntOp $PostCount $PostCount + 1


    • #3
      I did read it

      I saw that and did my best to understand it. However, my problem is slightly different in that my icon never works, so it is not just a problem with changing the icon but getting it to show at all. And as I said, I am learning NSIS so I don't understand how I need to change my script to overcome this problem by reading the example in that forum answer. It is very complicated.

      What do I need to add to my NSIS script to make my icon show visible?


      • #4
        Try changing the output directory before creating the shortcuts, like this:
        SetOutPath "$SMPROGRAMS\ObitEdit"
        CreateShortCut "$SMPROGRAMS\ObitEdit\ObitEdit.lnk" "$INSTDIR\ObitEdit.jar" "" "$INSTDIR\odt_log.ico"
        SetOutPath "$DESKTOP"
        CreateShortCut "$DESKTOP\ObitEdit.lnk" "$INSTDIR\ObitEdit.jar" "" "$INSTDIR\odt_log.ico"
        "Only a MouseHelmet will save you from a MouseTrap" -Jason Ross (Me)
        NSIS 3 POSIX Ninja
        Wiki Profile


        • #5
          Originally Posted by ajrjaneway View Post
          However, my problem is slightly different in that my icon never works, so it is not just a problem with changing the icon but getting it to show at all.
          If you install to c:\test or something simple like that, does it still fail to display the icon?

          Is the .ico a valid icon? Does odt_log.ico display correctly in Explorer?
          IntOp $PostCount $PostCount + 1


          • #6
            Thank you for the suggestions.

            I tried adding the SetOutPath as JasonFriday13 suggested, but it made no difference.

            I tried installing it in c:\test but that made no difference.

            Yes, I see the icon in Explorer and in fact when I execute the .jar (see screenshot).

            You can see the icon in Explorer on the right, the logo in the task bar in the bottom and the icon in the GUI in the upper left hand corner.

            But I still don't see it in the Start menu or on the desktop. I can change it (using Properties) in either place and then it is visible.


            • #7
              NSIS just uses the normal shortcut API so I'm not sure why it is not working. Please attach a zip file containing the generated broken shortcut and the icon and I'll try to take a look with some of my special shortcut tools.
              IntOp $PostCount $PostCount + 1


              • #8
                Here's the information

                Here are the files you requested, Anders. I hope I did it right. I've never tried to zip a shortcut before.

                For what it's worth, it doesn't work on 32-bit machines either. I even tried compiling my NSIS script on the 32-bit machine, but it made no difference.

                I really appreciate your help.
                Attached Files


                • #9
                  The icon contains two identical versions of the 48x48x32bpp image which is pointless but probably not harmful.

                  The real problem seems to be that the shortcut icon path is "C:\Program Files (x86)\ODT\ObitEdit2.0\odt_log.ico" but your icon is called "odt_logo.ico"!

                  The shortcut also contains the problematic %ProgramFiles% path that leads to 64-bit troubles but that is a different issue:

                  Ansi: %ProgramFiles%\ODT\ObitEdit2.0\odt_log.ico
                  Unicode: %ProgramFiles%\ODT\ObitEdit2.0\odt_log.ico
                  Just correct the icon path and it should work in most places...
                  IntOp $PostCount $PostCount + 1


                  • #10
                    Well, don't I feel silly. Now I only have that 64-bit thing about changing the icon, but as you say, it's a minor annoyance.

                    Thank you so much for your patience and your help.