Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QT installer framework to set user PATH environment variable
Forum Updated to NodeBB v4.3 + New Features

QT installer framework to set user PATH environment variable

Scheduled Pinned Locked Moved Unsolved General and Desktop
13 Posts 8 Posters 4.2k Views 2 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.
  • P Pauly

    My application needs external dll (lets call it a.dll), and I think that a.dll calls other dll relative to its location. I tested it that I can't just move a.dll to same directory of my exe, but if I set the environment variable everything will work fine...

    aha_1980A Offline
    aha_1980A Offline
    aha_1980
    Lifetime Qt Champion
    wrote on last edited by
    #4

    @Pauly

    tested it that I can't just move a.dll to same directory of my exe, but if I set the environment variable everything will work fine...

    That sounds strange. On Windows, both should work the same.

    I'd very upset if your app would modify my PATH. There are already enough strange entries that causes problems for other apps, e.g.

    Qt has to stay free or it will die.

    1 Reply Last reply
    1
    • P Offline
      P Offline
      Pauly
      wrote on last edited by
      #5

      I think the a.dll is expecting some fix relative directory structure of dll (and other things). I think Windows program add environment variable all the time? Or can I create my own variable?

      aha_1980A 1 Reply Last reply
      0
      • SGaistS Offline
        SGaistS Offline
        SGaist
        Lifetime Qt Champion
        wrote on last edited by
        #6

        Then you should check what exactly is expected for these .dlls.

        As @aha_1980, there are indeed lots of application that modify the PATH environment variable for usually no really good reasons and that can be mighty annoying.

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        1 Reply Last reply
        0
        • P Pauly

          I think the a.dll is expecting some fix relative directory structure of dll (and other things). I think Windows program add environment variable all the time? Or can I create my own variable?

          aha_1980A Offline
          aha_1980A Offline
          aha_1980
          Lifetime Qt Champion
          wrote on last edited by
          #7

          @Pauly I just hunted a bug where an app didn't work.

          It turned out, the app was using the wrong Qt DLLs from QtCreator, because that one was added to PATH

          So just think, fixing your case might break others.

          Qt has to stay free or it will die.

          1 Reply Last reply
          1
          • P Offline
            P Offline
            Pauly
            wrote on last edited by
            #8

            Understood... So is there a way to specify relative path to a particular dll in Qt project, just as if that is added to the environment variable? That may solve my need without messing with the environment variable.

            fcarneyF 1 Reply Last reply
            0
            • R Offline
              R Offline
              Roman2403
              wrote on last edited by
              #9

              I have same problem, but on uninstall process, also, i get errors with "Error during uninstallation: " with empty description.

              I think, it happens because "addElevatedOperation" must have both DO and UNDO steps(but i dont know how to add UNDO step for uninstall)
              DO on installation step, UNDO on uninstall. Does anyone know how to solve this problem?

              Component.prototype.createOperations = function()
              {
                 component.createOperations();
                 if(installer.isInstaller())
                 {
                  component.addElevatedOperation("EnvironmentVariable","GST_PLUGIN_PATH", gstPluginPath, persistently, false);
                  component.addElevatedOperation("EnvironmentVariable","GST_PLUGIN_SYSTEM_PATH", gstPluginSystemPath, persistently, false);
                  component.addElevatedOperation("EnvironmentVariable","GSTREAMER_1_0_ROOT_X86", gstreamerRootPath, persistently, false);
                 }
              
              1 Reply Last reply
              0
              • P Pauly

                Understood... So is there a way to specify relative path to a particular dll in Qt project, just as if that is added to the environment variable? That may solve my need without messing with the environment variable.

                fcarneyF Offline
                fcarneyF Offline
                fcarney
                wrote on last edited by
                #10

                @Pauly
                Does this work?

                qputenv("QT_IM_MODULE", QByteArray("qtvirtualkeyboard"));
                

                Obviously put in your own values for the path variable "QT_IM_MODULE" and its set to value "qtvirtualkeyboard".

                C++ is a perfectly valid school of magic.

                1 Reply Last reply
                0
                • M Offline
                  M Offline
                  MikePooh
                  wrote on last edited by MikePooh
                  #11

                  Try this

                  var winpath = installer.environmentVariable("PATH");
                  component.addOperation( "Execute", "setx", ["PATH", "\"" + @TargetDir@ + winpath + "\""] ); 
                  

                  to add to user PATH or

                  component.addOperation( "Execute", "setx", ["/M", "PATH",  "\"" + @TargetDir@ + winpath + "\""] ); 
                  

                  to add to system PATH (admin rights might be provided)

                  Be noted that setx command truncate PATH to 1024 symbols. That mean, it might break the system in case the PATH variable was longer.

                  1 Reply Last reply
                  0
                  • R Offline
                    R Offline
                    Renjith R
                    wrote on last edited by
                    #12

                    In the above-mentioned code by @MikePooh, installer.environmentVariable("PATH") returns both user and system environment variables.

                    So Is there any way to get only the USER environment or only the system environment variable? Otherwise, it will write system variables to user path or vise versa.

                    K 1 Reply Last reply
                    0
                    • R Renjith R

                      In the above-mentioned code by @MikePooh, installer.environmentVariable("PATH") returns both user and system environment variables.

                      So Is there any way to get only the USER environment or only the system environment variable? Otherwise, it will write system variables to user path or vise versa.

                      K Offline
                      K Offline
                      kugua
                      wrote on last edited by
                      #13

                      @Renjith-R hello,Have you found a solution later on,to get only the USER environment or only the system environment variable

                      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