Archive: Custom Icon


Custom Icon
Does anyone know if a custom icon can be set anywhere in NSIS? My program, Firebird, has a bug and an icon cannot be set on the .exe, even by using programs such as resHack so I'm hoping I can tell it to use a custom icon.

Thanks for your help.


!define MUI_ICON "${NSISDIR}\Contrib\Icons\Youriconname.ico"
!define MUI_UNICON "${NSISDIR}\Contrib\Icons\YourIconname.ico"

Copy your Icons in the folder


the previous example applies to installers with modern interface. if you use the standard interface use

Icon [path\]icon.ico
UninstallIcon [path\]icon.ico

you can find this in the documentation


Thanks for your reply but I want to set the icon for the program itself. ie: MozillaFirebird.exe. When compiling this program, it won't create the program icon and I was hoping I would be able to set it with the installer.


In reading over my post, I did not make it clear. Here is a portion of my script:

; Subsection about shortcuts (desktop, startmenu, quicklaunch)
;

SubSection /e "${NAME_SecAddShortcuts}" SecAddShortcuts

Section "${NAME_SecAddDesktopShortcut}" SecAddDesktopShortcut
CreateShortCut "$DESKTOP\${DESC_DesktopShortcut}.lnk" \
"$INSTDIR\${EXE}" "" "$INSTDIR\${EXE}" 0
SectionEnd

Section "${NAME_SecAddStartShortcuts}" SecAddStartShortcuts
CreateDirectory "$SMPROGRAMS\${DESC_StartDir}"
CreateShortCut "$SMPROGRAMS\${DESC_StartDir}\${DESC_StartUninst}.lnk" \
"$INSTDIR\${UNINSTALLER}" "" "$INSTDIR\${UNINSTALLER}" 0
CreateShortCut "$SMPROGRAMS\${DESC_StartDir}\${DESC_StartProg}.lnk" \
"$INSTDIR\${EXE}" "" "$INSTDIR\${EXE}" 0
SectionEnd

Section "${NAME_SecAddQuicklaunchShortcut}" SecAddQuicklaunchShortcut
CreateShortCut "$QUICKLAUNCH\${DESC_Quicklaunch}.lnk" \
"$INSTDIR\${EXE}" "" "$INSTDIR\${EXE}" 0
SectionEnd

SubSectionEnd

I need to tell the installer to use my icon located here: [D:\!Browsers\InTouch\intouch\32i.ico]


ok... sinxe your icon for the shorcut isn't the same of the installer or the uninstaller...
Try this:


CreateShortCut "short.lnk" "$INSTDIR\${exe}.exe" "" \
"$INSTDIR\theico.ico" 0 "SW_SHOWNORMAL" "" "Hi. I'm a shortcut"


Where "$INSTDIR\theico.ico" is the installed path of the icon...

Please forgive me as I am a noobie. I tried entering the lines you suggested and I get an error. Do I replace

CreateShortCut "$DESKTOP\${DESC_DesktopShortcut}.lnk" \
"$INSTDIR\${EXE}" "" "$INSTDIR\${EXE}" 0

with

CreateShortCut "short.lnk" "$INSTDIR\${exe}.exe" "" \
"$INSTDIR\D:\!Browsers\InTouch\intouch\32i.ico" 0 "SW_SHOWNORMAL" "" "Intouch"

If so, I receive the following error:

CreateShortCut: "short.lnk"->"$INSTDIR\InTouch.exe.exe" icon:$INSTDIR\D:\!Browsers\InTouch\intouch\32i.ico,0, showmode=0x1, hotkey=0x0, comment=Intouch
Error: Can't add entry, no section or function is open!
Error in script "D:\!Browsers\InTouch\InTouchinstaller\installer.nsi" on line 216 -- aborting creation process


You must place the code in a Function or section.

Example

Section "Install my program"
File "/oname=$INSTDIR\${exe}.exe" "${exe}.exe"
CreateShortCut "short.lnk" "$INSTDIR\${exe}.exe" "" \
"$INSTDIR\D:\!Browsers\InTouch\intouch\32i.ico" 0 "SW_SHOWNORMAL" "" "Intouch"
SectionEnd


-Stu