问题
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@/Appname.exe","iconId=0");
with -param
as the last argument too.
来源:https://stackoverflow.com/questions/46040537/qt-installer-framework-create-shortcut-with-argument