Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Qt Installer Framework : Create shortcut on the desktop

I use Qt Installer framework 1.5

After the installation, I would like to add a shortcut on the desktop.

In my file installscript.qs, I tried :

Component.prototype.createOperationsForPath = function()
{
  if (installer.value("os") === "win")
  {
    try {
      component.addOperation("CreateShortcut", "@TargetDir@/App.exe", "@DesktopDir@/App.lnk");
    }
    catch (e) {
      print(e);
    }
  }
}

But it doesn't work, the shortcut isn't created and I don't have any error messages. The documentation on Internet is really light.

Any idea ? Thank you

like image 281
Thomas K Avatar asked Feb 22 '14 15:02

Thomas K


1 Answers

Try this. It's working for me.

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);
    }
}
like image 74
MBach Avatar answered Sep 24 '22 00:09

MBach