简体   繁体   English

如何更改 nsis 快捷方式路径的起点?

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

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

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. 换句话说,您需要使用“SetOutPath”为快捷方式指定“Start In”文件夹。 This is why the solution posted by Zerofiz works: 这就是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开头。

Try this: 试试这个:

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

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.注意:如果您只想将“开始于:”字段留空,您还可以使用文档链接中提到的/NoWorkingDir标志。 http://nsis.sourceforge.net/Docs/Chapter4.html#4.9.3.4 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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何将快捷方式固定到NSIS的开始菜单? - How to pin shortcut to start menu with NSIS? 如何更改 Electron Builder 创建的应用程序快捷方式中的“开始”路径? - How to change the "Start in" path in a shortcut for an application created by Electron Builder? C ++:如何在Windows的“开始”菜单中创建快捷方式 - C++: How do I create a Shortcut in the Start Menu on Windows 如何让NSIS等待MSI? - How do I get NSIS to wait on an msi? 使用 NSIS,卸载程序快捷方式不会显示在开始菜单中 - Using NSIS the Uninstaller shortcut does not show up in the Start Menu WiX:如何创建开始菜单快捷方式而不将其放在文件夹中? - WiX: How do I create Start Menu shortcut without placing it in a folder? 如何使用Powershell在快捷方式中编辑Target属性以在文件路径之后包含字符? - How do I edit the Target property in a shortcut to include a character after the file path using Powershell? 带有java参数的NSIS快捷方式 - NSIS shortcut with java parameters 如何从用户目录开始文件路径? - How do I start the file path from the users directory? 如何在NSIS安装程序中的完成页面上添加桌面快捷方式选项? - How to Add a Desktop Shortcut Option on Finish Page in NSIS installer?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM