Qt Installer Framework: Создать ярлык на рабочем столе
Я использую Qt Installer Framework 1.5
После установки я бы хотел добавить ярлык на рабочий стол.
В моем файле installscript.qs я попытался:
Component.prototype.createOperationsForPath = function()
{
if (installer.value("os") === "win")
{
try {
component.addOperation("CreateShortcut", "@TargetDir@/App.exe", "@DesktopDir@/App.lnk");
}
catch (e) {
print(e);
}
}
}
Но это не работает, ярлык не создан, и у меня нет сообщений об ошибках. Документация в интернете действительно легкая.
Любая идея? Спасибо
1 ответ
Попробуй это. Это работает для меня.
Component.prototype.createOperations = function()
{
try {
// call the base create operations function
component.createOperations();
if (installer.value("os") == "win") {
try {
var userProfile = installer.environmentVariable("USERPROFILE");
installer.setValue("UserProfile", userProfile);
component.addOperation("CreateShortcut", "@TargetDir@\\MiamPlayer.exe", "@UserProfile@\\Desktop\\MiamPlayer.lnk");
} catch (e) {
// Do nothing if key doesn't exist
}
}
} catch (e) {
print(e);
}
}
Я знаю, что этот ответ приходит очень поздно, но надеюсь, что он поможет другим пользователям:
(Qt 5.13)
component.addOperation("CreateShortcut",
"@TargetDir@/App.exe",// target
"@DesktopDir@/App.lnk",// link-path
"workingDirectory=@TargetDir@",// working-dir
"iconPath=@TargetDir@/App.exe", "iconId=0",// icon
"description=Start App");// description