Archive: Problem with shortcut icon and NSIS


Problem with shortcut icon and NSIS
I am trying to get an external icon installed in the program .lnk but it is not working for me. The following is the nsis.nsi statements that are involved:

!define APP_NAME "Fescue"
!define VERSION "01.00.00.00"
!define DESCRIPTION "Application"
!define INSTALLER_NAME "\Dropbox\Fescue\setup.exe"
!define MAIN_APP_EXE "Fescue.rex"
!define MAIN_APP_ICO "Fescue.ico"
!define INSTALL_TYPE "SetShellVarContext current"

!ifdef REG_START_MENU
!insertmacro MUI_STARTMENU_WRITE_BEGIN Application
CreateDirectory "$SMPROGRAMS\$SM_Folder"
CreateShortCut "$SMPROGRAMS\$SM_Folder\${APP_NAME}.lnk" \
"$INSTDIR\${MAIN_APP_EXE}" "$INSTDIR\${MAIN_APP_ICO}"
CreateShortCut "$DESKTOP\${APP_NAME}.lnk" "$INSTDIR\${MAIN_APP_EXE}" \
"$INSTDIR\${MAIN_APP_ICO}"
CreateShortCut "$SMPROGRAMS\$SM_Folder\Uninstall ${APP_NAME}.lnk" \
"$INSTDIR\uninstall.exe"
!endif

When I look at the .lnk file with a hex editor, or select properties on the program icon, it appears the .ico file information has been appended to the end of the target field for the program. If I manually select to change the icon on the properties panel, it works okay, but the .ico information is located in a different place in the .lnk file. Suggestions on how to get around this problem? This is on a Windows XP Pro system.


Make sure $INSTDIR\${MAIN_APP_EXE} and ${MAIN_APP_ICO} exist before you call CreateShortcut...


Thanks Anders, but if you read my original post, the following defines are at the first part of my script:
!define MAIN_APP_EXE "Fescue.rex"
!define MAIN_APP_ICO "Fescue.ico"
Is there another solution or work around?


Anders means that the folders and files must exist before the shortcut is created.


Sorry for being so dense, but see the following from my original post:
CreateDirectory "$SMPROGRAMS\$SM_Folder"
CreateShortCut "$SMPROGRAMS\$SM_Folder\${APP_NAME}.lnk" \
"$INSTDIR\${MAIN_APP_EXE}" "$INSTDIR\${MAIN_APP_ICO}"
CreateShortCut "$DESKTOP\${APP_NAME}.lnk" "$INSTDIR\${MAIN_APP_EXE}" \
"$INSTDIR\${MAIN_APP_ICO}"

As I stated in the original post, the shortcut is there with the execution parameter filled in and the ico parameter is also there, but following the execution parameter in the target field like:
C:\Fescue\fescue.rex C:\Fescue\fescue.ico
the fescue.ico file is also in the C:\Fescue folder after the setup.exe install has been run. I suspect the problem is with the executable not being an .exe or .dll, but the .rex is defined to have ooRexx.exe start and that is passed as the startup parameter. That all works okay - just the icon is NOT present on either the desktop or the Start Menu folder. I am asking if there is a workaround or how this should be handled.


Arth, you still don't seem to be answering Anders' concern. When you execute the code to create the SMPrograms folder and the shortcut, has the executable file been extracted yet? If the file isn't yet on the target computer, the shortcut icon won't be set properly.


You forgot a parameter:

Createshortcut foo.lnk bar.exe "" baz.ico