Qt Installer Framework : Create shortcut with argument

。_饼干妹妹 提交于 2019-12-20 02:26:11

问题


Does anyone know how to add an argument to a shortcut created by QT IFW? I need the exe it launches to be passed an argument.

Here's what works (with no argument):

component.addOperation( "CreateShortcut",
    "@TargetDir@/MyApp.exe",
    "@StartMenuDir@/@ProductName@.lnk",
    "workingDirectory=@TargetDir@",
    "iconPath=@TargetDir@/MyApp.exe",
    "iconId=0");

I want the exe to get something like -c passed to it. I've tried a few approaches, but am not having any luck.


回答1:


Qt Installer framework documentation is very poor, but you can read in operations the following: "CreateShortcut" filename linkname [arguments]

Creates a shortcut from the file specified by filename to linkname. On Windows, this creates a .lnk file which can have arguments. On Unix, this creates a symbolic link.

So do it in that way:

component.addOperation("CreateShortcut", "@TargetDir@/Appname.exe", "@DesktopDir@/Appname.lnk", "-param");

Result in lnk target element: C:\YourAppDirectory\Appname.exe -param

EDIT: Your case works as well for me:

component.addOperation( "CreateShortcut","@TargetDir@/Appname.exe","@StartMenuDir@/@‌​ProductName@.lnk", "-param", "workingDirectory=@TargetDir@",  "iconPath=@TargetDir@/Appnam‌​e.exe","iconId=0");

with -param as the last argument too.



来源:https://stackoverflow.com/questions/46040537/qt-installer-framework-create-shortcut-with-argument

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!