windows 如何更改 nsis 快捷方式路径中的开始位置?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/973469/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 12:37:05  来源:igfitidea点击:

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

windowsinstallernsis

提问by Lodle

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.

我有一个用于我正在处理的应用程序的 nsis 安装程序脚本,它可以在桌面和开始菜单文件夹中放置一个快捷方式,但每个快捷方式在路径中都有错误的开始,因此应用程序将数据文件保存到快捷方式所在的位置.

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

采纳答案by Calvin Allen

Try this:

尝试这个:

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

回答by Lodle

Please see the following page of the NSIS documentation:

请参阅 NSIS 文档的以下页面:

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

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."

“$OUTDIR 用于工作目录。您可以在创建快捷方式之前使用 SetOutPath 更改它。”

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:

换句话说,您需要使用“SetOutPath”来指定快捷方式的“Start In”文件夹。这就是 Zerofiz 发布的解决方案有效的原因:

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.

这将导致快捷方式在 $INSTDIR 中启动。