Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Installation and Deployment
  4. creating desktop shortcut during installation
Forum Updated to NodeBB v4.3 + New Features

creating desktop shortcut during installation

Scheduled Pinned Locked Moved Solved Installation and Deployment
8 Posts 2 Posters 2.7k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • mzimmersM Offline
    mzimmersM Offline
    mzimmers
    wrote on last edited by
    #1

    Hi all -

    I've been asked to modify my installer to create a desktop shortcut. I've done a little web searching, and the answer seems to lie in creating a javascript (or maybe two). The Qt Installer Framework Manual seems somewhat brief and incomplete, so I have a few questions:

    • the docs refer to two kinds of scripts: controller scripting and component scripting. From the examples, it seems that I want to make a component script. Correct?
    • also from the examples, the filename should be installscript.qs. Do I have to tell binarycreator to use this .qs? I don't see any hopeful options in the binarycreator help for this.
    • I've seen examples use createOperations, and newOperation. Which is appropriate for my use?
    • if I call console.log() from within my installscript, should I expect to see its output in the installationlog.txt file?

    I'm sure I'll have some more questions, but this will get me started. Thanks...

    J.HilkJ 1 Reply Last reply
    0
    • mzimmersM Offline
      mzimmersM Offline
      mzimmers
      wrote on last edited by
      #2

      BTT...anyone want to help? Thanks...

      1 Reply Last reply
      0
      • mzimmersM mzimmers

        Hi all -

        I've been asked to modify my installer to create a desktop shortcut. I've done a little web searching, and the answer seems to lie in creating a javascript (or maybe two). The Qt Installer Framework Manual seems somewhat brief and incomplete, so I have a few questions:

        • the docs refer to two kinds of scripts: controller scripting and component scripting. From the examples, it seems that I want to make a component script. Correct?
        • also from the examples, the filename should be installscript.qs. Do I have to tell binarycreator to use this .qs? I don't see any hopeful options in the binarycreator help for this.
        • I've seen examples use createOperations, and newOperation. Which is appropriate for my use?
        • if I call console.log() from within my installscript, should I expect to see its output in the installationlog.txt file?

        I'm sure I'll have some more questions, but this will get me started. Thanks...

        J.HilkJ Offline
        J.HilkJ Offline
        J.Hilk
        Moderators
        wrote on last edited by
        #3

        hi @mzimmers

        the InstallerFramework is not widely used, so help will be sparse :(

        It is black magic for me too, but I can share my installerscript.qs that I use.

        The script lives in the meta folder of the main packages and what it does is offers the user a checkbox to create a desktop icon

        function Component()
        {
            // constructor
            if (!systemInfo.productVersion.startsWith("7")){
                component.enabled = true;
        
                component.loaded.connect(this, Component.prototype.loaded);
            }else{
                component.enabled = false;
            }
        }
        
        Component.prototype.createOperations = function()
        {
            try {
                // call the base create operations function
                component.createOperations();
            } catch (e) {
                console.log(e);
            }
        	
            if (systemInfo.productType === "windows") {
                    component.addOperation("CreateShortcut", "@TargetDir@/myApp.exe", "@StartMenuDir@/myApp.lnk",
                "workingDirectory=@TargetDir@");
                    component.addOperation("CreateShortcut", "@TargetDir@/myApp.exe", "@HomeDir@/Desktop/myApp.lnk");
            }
        }
        

        inside the package.xml you'll have to add the script via

        <Default>script</Default>

        <Script>installscript.qs</Script>

        I hope this helps!


        Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


        Q: What's that?
        A: It's blue light.
        Q: What does it do?
        A: It turns blue.

        mzimmersM 1 Reply Last reply
        1
        • J.HilkJ J.Hilk

          hi @mzimmers

          the InstallerFramework is not widely used, so help will be sparse :(

          It is black magic for me too, but I can share my installerscript.qs that I use.

          The script lives in the meta folder of the main packages and what it does is offers the user a checkbox to create a desktop icon

          function Component()
          {
              // constructor
              if (!systemInfo.productVersion.startsWith("7")){
                  component.enabled = true;
          
                  component.loaded.connect(this, Component.prototype.loaded);
              }else{
                  component.enabled = false;
              }
          }
          
          Component.prototype.createOperations = function()
          {
              try {
                  // call the base create operations function
                  component.createOperations();
              } catch (e) {
                  console.log(e);
              }
          	
              if (systemInfo.productType === "windows") {
                      component.addOperation("CreateShortcut", "@TargetDir@/myApp.exe", "@StartMenuDir@/myApp.lnk",
                  "workingDirectory=@TargetDir@");
                      component.addOperation("CreateShortcut", "@TargetDir@/myApp.exe", "@HomeDir@/Desktop/myApp.lnk");
              }
          }
          

          inside the package.xml you'll have to add the script via

          <Default>script</Default>

          <Script>installscript.qs</Script>

          I hope this helps!

          mzimmersM Offline
          mzimmersM Offline
          mzimmers
          wrote on last edited by
          #4

          @J-Hilk thanks for replying! This is very helpful. I think the main difference between yours and mine is the location -- I grabbed my script from an example that had it in the installer directory, not the meta sub-directory.

          I notice, also that your OS check is:

              if (systemInfo.productType === "windows") {
          

          whereas mine is:

                  if (systemInfo.ProductType == "win") {
          

          which I find odd, but since yours works, I'll go with the winner.

          What does this line do?

              if (!systemInfo.productVersion.startsWith("7")){
          

          Thanks again...

          J.HilkJ 1 Reply Last reply
          0
          • mzimmersM mzimmers

            @J-Hilk thanks for replying! This is very helpful. I think the main difference between yours and mine is the location -- I grabbed my script from an example that had it in the installer directory, not the meta sub-directory.

            I notice, also that your OS check is:

                if (systemInfo.productType === "windows") {
            

            whereas mine is:

                    if (systemInfo.ProductType == "win") {
            

            which I find odd, but since yours works, I'll go with the winner.

            What does this line do?

                if (!systemInfo.productVersion.startsWith("7")){
            

            Thanks again...

            J.HilkJ Offline
            J.HilkJ Offline
            J.Hilk
            Moderators
            wrote on last edited by
            #5

            @mzimmers said in creating desktop shortcut during installation:

            if (!systemInfo.productVersion.startsWith("7")){

            it checks if it's windows 7 or newer. I only support win 10 so I disable the component in the installer if I detect win7


            Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


            Q: What's that?
            A: It's blue light.
            Q: What does it do?
            A: It turns blue.

            mzimmersM 1 Reply Last reply
            0
            • J.HilkJ J.Hilk

              @mzimmers said in creating desktop shortcut during installation:

              if (!systemInfo.productVersion.startsWith("7")){

              it checks if it's windows 7 or newer. I only support win 10 so I disable the component in the installer if I detect win7

              mzimmersM Offline
              mzimmersM Offline
              mzimmers
              wrote on last edited by mzimmers
              #6

              @J-Hilk OK, thanks.

              I borrowed from your script, moved mine to meta and rebuilt the installer -- no change. Am I possibly missing something like a binarycreator option to pick up scripts? Here's the line I use to create the installer:

              C:\discovery_utility\installer>binarycreator.exe -c config\config.xml -p packages cd_discovery_installer.exe
              

              EDIT: the installscript line was commented out in my package.xml file (no idea why). I removed the commenting, and got this at runtime:

              Exception while loading the component script ":\\metadata\com.vendor.product\installscript.qs": Error: Function.prototype.connect: target is not a function on line number: 7
              

              This is line 7:

                      component.loaded.connect(this, Component.prototype.loaded);
              

              But, this is definitely progress.

              J.HilkJ 1 Reply Last reply
              0
              • mzimmersM mzimmers

                @J-Hilk OK, thanks.

                I borrowed from your script, moved mine to meta and rebuilt the installer -- no change. Am I possibly missing something like a binarycreator option to pick up scripts? Here's the line I use to create the installer:

                C:\discovery_utility\installer>binarycreator.exe -c config\config.xml -p packages cd_discovery_installer.exe
                

                EDIT: the installscript line was commented out in my package.xml file (no idea why). I removed the commenting, and got this at runtime:

                Exception while loading the component script ":\\metadata\com.vendor.product\installscript.qs": Error: Function.prototype.connect: target is not a function on line number: 7
                

                This is line 7:

                        component.loaded.connect(this, Component.prototype.loaded);
                

                But, this is definitely progress.

                J.HilkJ Offline
                J.HilkJ Offline
                J.Hilk
                Moderators
                wrote on last edited by
                #7

                @mzimmers mmh

                I don't have more ideas.

                Have you checked the short cut example in the docs ?

                https://doc.qt.io/qtinstallerframework/qt-installer-framework-startmenu-example.html


                Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


                Q: What's that?
                A: It's blue light.
                Q: What does it do?
                A: It turns blue.

                1 Reply Last reply
                0
                • mzimmersM Offline
                  mzimmersM Offline
                  mzimmers
                  wrote on last edited by
                  #8

                  Well, I got it to create the shortcut (unconditionally, but that's better than nothing). I just commented out that line 7 (above) and it worked.

                  I do wish someone with more knowledge would augment the docs on the installer, but I can close this out. Thanks for the help.

                  1 Reply Last reply
                  0

                  • Login

                  • Login or register to search.
                  • First post
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • Users
                  • Groups
                  • Search
                  • Get Qt Extensions
                  • Unsolved