Archive: CreateShortcut Bug?


Hi,

Have a look at this code:

CreateDirectory $SMPROGRAMS\Program
CreateShortcut $SMPROGRAMS\Program\Program.lnk $INSTDIR\PROGRAM.EXE
CreateShortcut "$SMPROGRAMS\Uninstall Program.lnk" $INSTDIR\REMOVE.EXE


Now, have a look at this code, which puts the icons in the folder containing the installer:

SetOutPath $SMPROGRAMS\Program
CreateShortcut Program.lnk $INSTDIR\PROGRAM.EXE
CreateShortcut "Uninstall Program.lnk" $INSTDIR\REMOVE.EXE


Does anyone else think that this code should also work? It definitely seems more efficient and more logical, because it would then work more like the File command. You specify the OutPath, and then not have to specify an absolute path with CreateShortcut.

hi,

yeah, you are right, it should, but it doesn't :)

that would be a lot better to understand (not only for newbies) and it would fit to the logic of the other commands like "File".

cu yzo


Not a bug only bad use of feature.
I think you guys have missed the point with SetOutPath.
SetOutPath when used together with CreateShortcut sets the Working dircetory for the shortcut since that parameter disappered some versions ago. But you ar absolutely right that It could be used with the filename for the shortcut, reimplementing the Working directory as a parameter again.


hi,

yeah sure, createshortcut uses the outpath as working dir since version 1.0i, but that is IMHO the wrong logic.

it should point to the path where the Shortcut has to be created and the working dir should be set with a parameter.

well, i guess that is a question of taste.

cu yzo


I wasn't aware of SetOutPath setting the working directory for CreateShortcut.

But personally, I don't think I'll ever need the working directory to be anything other than $INSTDIR.

I think NSIS should automatically set the working directory to the folder of the file the shortcut refers to, unless otherwise advised.

Example:

CreateShortcut $INSTDIR\PROGRAM.EXE
Sets the working directory to $INSTDIR.

CreateShortcut C:\WINDOWS\NOTEPAD.EXE
Sets the working directory to C:\WINDOWS.