How do i change the start in path of a shortcut for nsis?
Asked Answered
S

3

23

I have an nsis installer script for the application im working on and it can place a shortcut on the desktop and in the start menu folder but each shortcut has the wrong start in path and as such the app saves data files to where the short cut is.

Is there an easy way to change the start in path as the documentation was less than helpful on the matter?

Section "Desktop Shortcut" SHORTCUT
    SetOutPath "$DESKTOP"
    CreateShortcut "${FULL_APP_NAME}.lnk" "$INSTDIR\${APP_NAME}.exe" "" "$ICONDIR\${DESKICO}"
SectionEnd
Slavery answered 10/6, 2009 at 2:47 Comment(0)
B
16

Try this:

Section "Desktop Shortcut" SHORTCUT
     SetOutPath "$INSTDIR"
     CreateShortcut "$DESKTOP\${FULL_APP_NAME}.lnk" "$INSTDIR\${APP_NAME}.exe" "" "$ICONDIR\${DESKICO}"
SectionEnd
Billat answered 10/6, 2009 at 3:18 Comment(0)
K
24

Please see the following page of the NSIS documentation:

http://nsis.sourceforge.net/Docs/Chapter4.html#4.9.3.4

In particular, please look at the sentence that reads:

"$OUTDIR is used for the working directory. You can change it by using SetOutPath before creating the Shortcut."

In other words, you need to use 'SetOutPath' to specify the "Start In" folder for the shortcut. This is why the solution posted by Zerofiz works:

Section "Desktop Shortcut" SHORTCUT
    SetOutPath "$INSTDIR"
    CreateShortcut "$DESKTOP\${FULL_APP_NAME}.lnk" "$INSTDIR\${APP_NAME}.exe" "" "$ICONDIR\${DESKICO}"
SectionEnd

This will cause the shortcut to start in $INSTDIR.

Khajeh answered 14/3, 2010 at 1:3 Comment(0)
B
16

Try this:

Section "Desktop Shortcut" SHORTCUT
     SetOutPath "$INSTDIR"
     CreateShortcut "$DESKTOP\${FULL_APP_NAME}.lnk" "$INSTDIR\${APP_NAME}.exe" "" "$ICONDIR\${DESKICO}"
SectionEnd
Billat answered 10/6, 2009 at 3:18 Comment(0)
G
0

Note: if you just want the "Start in:" field to be blank, you can also use the /NoWorkingDir flag mentioned in the link to the documentation. http://nsis.sourceforge.net/Docs/Chapter4.html#4.9.3.4

Section "Desktop Shortcut" SHORTCUT
    SetOutPath "$INSTDIR"
    CreateShortcut /NoWorkingDir "$DESKTOP\${FULL_APP_NAME}.lnk" "$INSTDIR\${APP_NAME}.exe" "" "$ICONDIR\${DESKICO}"
SectionEnd
Gianina answered 1/4, 2022 at 22:59 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.