Archive: Trouble with CreateShortCut


Trouble with CreateShortCut
I keep getting an error when trying to use the CreateShortCut command.
I am trying to create a shortcut for a java application with an icon for the shortcut, the shortcut is d I have been using.

CreateShortCut "$SMSTARTUP\WhereIs.lnk" "C:\jdk\bin\javaw.exe" "$OUTDIR\image\whereis.ico" 1 "SW_SHOWMINIMIZED" "ALT|CONTROL|w"

And this is what makeNSIS.exe tells me.

CreateShortCut: cannot interpret icon index
Usage: CreateShortCut shortcut_name.lnk shortcut_target [parameters [icon_file [
icon index [showmode [hotkey]]]]]
showmode=(SW_SHOWNORMAL|SW_SHOWMAXIMIZED|SW_SHOWMINIMIZED)
hotkey=(ALT|CONTROL|EXT|SHIFT)|(F1-F24|A-Z)
Error in script "C:\WINDOWS.000\Skrivebord\whereis.nsi" on line 35 -- aborting creation process

I cant figure uot what I am doing wrong... hope somebody can help me.


The first icon index in a ICO, DLL or EXE file 0, not 1.


ramius is missing the parameters argument in his call to CreateShortCut.

But I get the same error if I try to pass the icon index through a variable:

>>>CreateShortCut "$SMPROGRAMS\$InstallerBrand\MyLink.lnk" "$INSTDIR\My.exe" "" "$INSTDIR\My.exe" "$IconIdx"

>>>CreateShortCut: cannot interpret icon index

If I replace $IconIdx with a number (e.g., 0 or 1) it compiles fine. Bug?


Not a bug of course, you're confusing compile time and run time. Variables are in action at run time.


But my user variable $InstallerBrand works fine in this case. Is it the difference between a string and an integer?


Compiler expects an integer for the specific parameter while the variable is empty when compiling. Try a definition instead, e.g. !define IconIdx "0".


Quite simply, the icon index has to be a static hard-coded value.

Stu


Met the same issue. It is quite strange that compile-time value is required here. Why? And how do I choose icon dynamically?