9

我使用 Qt Installer 框架 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);
    }
  }
}

但它不起作用,没有创建快捷方式,我也没有任何错误消息。互联网上的文档真的很轻。

任何想法 ?谢谢

4

2 回答 2

15

尝试这个。它对我有用。

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);
    }
}
于 2014-11-18T11:02:53.863 回答
12

我知道这个答案来得很晚,但我希望它可以帮助其他用户:

(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
于 2019-10-03T12:50:40.577 回答