1 Place this in blah.nsi
!define PROJECT_NAME "blah" OutFile "${PROJECT_NAME}.exe" InstallDir "$PROGRAMFILES\${PROJECT_NAME}" Section CreateDirectory "$SMPROGRAMS\${PROJECT_NAME}" CreateShortcut "$SMPROGRAMS\${PROJECT_NAME}\folder.lnk" "$INSTDIR\..\" SectionEnd
2 makensis blah.nsi
3 Run blah.exe
4 Start->All Programs->blah->folder
A Windows Explorer window opened to the folder.
A (broken) Windows shortcut. Instead am prompted with an "Open with" dialog since Windows seems to be confused what the shortcut is.
Right clicking on the shortcut actually shows that the shortcut Target type
is File
rather than expectedFile Folder
mingw32-nsis-2.46-9.fc19.x86_64
NSIS just calls IShellLink and does not change the path you give it in any way.
It is a well known issue that when you create a shortcut the target has to exist before you create the shortcut because Windows tries to store as much information about the target as possible and sometimes it is too smart for its own good.
When the target is a folder and it does not exist the final component in the PIDL gets stored as a SHDID_FS_FILE and not SHDID_FS_DIRECTORY. In this specific case the target does technically exist but Windows is not smart enough to figure this out. (If you run the example with "setup.exe /D=c:\foo" it would be broken no matter what since $instdir would not exist at all)
The way around this is to make sure the target exists before creating the shortcut.
If you absolutely need some relative path magic use:
Last edit: Anders 2017-06-05
Thank you that workaround worked for me.