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. Open .exe file from Qt GUI
Forum Updated to NodeBB v4.3 + New Features

Open .exe file from Qt GUI

Scheduled Pinned Locked Moved Unsolved General and Desktop
11 Posts 6 Posters 2.8k Views 3 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.
  • L linda

    Hi all,I have an executable file(e.g., test.exe) run in the cmd and I must run this test.exe with administrator right, the file is not working if not run with admin right. Now I am working on to create a Qt GUI with a pushbutton, once the button clicked, the test.exe will prompt up and run. I did some online research, it says that Qprocess could do it. May I know is it possible to do it with Qprocess and is there any example could show how to do it using Qprocess. Thanks!

    Pablo J. RoginaP Offline
    Pablo J. RoginaP Offline
    Pablo J. Rogina
    wrote on last edited by
    #2

    @linda assuming you're platform is Windows (you didn't state it properly in your issue details) you may want to take a look at runas feature. This answer may help you.

    Upvote the answer(s) that helped you solve the issue
    Use "Topic Tools" button to mark your post as Solved
    Add screenshots via postimage.org
    Don't ask support requests via chat/PM. Please use the forum so others can benefit from the solution in the future

    L 1 Reply Last reply
    3
    • mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by
      #3

      Hi
      If you can't make a manifest for test.exe or have issues with getting runas
      to display UAC dialog, then there is also
      http://www.soft.tahionic.com/download-run as admin console command/index.html
      which i use often to run stuff in bat/cmd files as admin.
      Works like a charm and its portable and can be run from any folder.

      L 1 Reply Last reply
      5
      • Pablo J. RoginaP Pablo J. Rogina

        @linda assuming you're platform is Windows (you didn't state it properly in your issue details) you may want to take a look at runas feature. This answer may help you.

        L Offline
        L Offline
        linda
        wrote on last edited by
        #4

        @Pablo-J.-Rogina
        Hi, thanks for the reply. In the future need to be cross-platform, but for now, i am trying to do it in windows only.
        The problem is I need to open the cmd in administrator mode then go the directory and key commands to run the test.exe, I not sure is it possible to do it with GUI, the command to execute test.exe will be code in the backend and once I clicked on the button, the test.exe will run it.

        1 Reply Last reply
        0
        • mrjjM mrjj

          Hi
          If you can't make a manifest for test.exe or have issues with getting runas
          to display UAC dialog, then there is also
          http://www.soft.tahionic.com/download-run as admin console command/index.html
          which i use often to run stuff in bat/cmd files as admin.
          Works like a charm and its portable and can be run from any folder.

          L Offline
          L Offline
          linda
          wrote on last edited by
          #5

          @mrjj
          Hi, thanks for the reply.

          0_1526439947149_4979ca69-8508-4f30-997d-a6e6003ff818-image.png

          It is similar to this code, the problem is I need to open the cmd in administrator mode then go the directory and key commands to run the test.exe, I not sure is it possible to do it with GUI, the command to execute test.exe will be code in the backend and once I clicked on the button, the test.exe will run it.

          jsulmJ Pablo J. RoginaP 2 Replies Last reply
          0
          • L linda

            @mrjj
            Hi, thanks for the reply.

            0_1526439947149_4979ca69-8508-4f30-997d-a6e6003ff818-image.png

            It is similar to this code, the problem is I need to open the cmd in administrator mode then go the directory and key commands to run the test.exe, I not sure is it possible to do it with GUI, the command to execute test.exe will be code in the backend and once I clicked on the button, the test.exe will run it.

            jsulmJ Offline
            jsulmJ Offline
            jsulm
            Lifetime Qt Champion
            wrote on last edited by
            #6

            @linda said in Open .exe file from Qt GUI:

            the problem is I need to open the cmd in administrator mode

            That's why "runas" was suggested. Did you check this option?

            https://forum.qt.io/topic/113070/qt-code-of-conduct

            L 1 Reply Last reply
            0
            • jsulmJ jsulm

              @linda said in Open .exe file from Qt GUI:

              the problem is I need to open the cmd in administrator mode

              That's why "runas" was suggested. Did you check this option?

              L Offline
              L Offline
              linda
              wrote on last edited by
              #7

              @jsulm
              I look through it and have some ideas, thanks for the reply!

              JonBJ 1 Reply Last reply
              0
              • L linda

                @jsulm
                I look through it and have some ideas, thanks for the reply!

                JonBJ Offline
                JonBJ Offline
                JonB
                wrote on last edited by
                #8

                @linda
                If your argument to execute() is actually any kind of literal string like you have typed here, it won't be right till you double those \s. Just saying....

                SGaistS 1 Reply Last reply
                1
                • L linda

                  @mrjj
                  Hi, thanks for the reply.

                  0_1526439947149_4979ca69-8508-4f30-997d-a6e6003ff818-image.png

                  It is similar to this code, the problem is I need to open the cmd in administrator mode then go the directory and key commands to run the test.exe, I not sure is it possible to do it with GUI, the command to execute test.exe will be code in the backend and once I clicked on the button, the test.exe will run it.

                  Pablo J. RoginaP Offline
                  Pablo J. RoginaP Offline
                  Pablo J. Rogina
                  wrote on last edited by
                  #9

                  @linda said in Open .exe file from Qt GUI:

                  It is similar to this code, the problem is I need to open the cmd in administrator mode then go the directory and key commands to run the test.exe,

                  As mentioned by @JonB you don't need to 'cd' to the folder where your .exe is located. Just use the proper path to it

                  Upvote the answer(s) that helped you solve the issue
                  Use "Topic Tools" button to mark your post as Solved
                  Add screenshots via postimage.org
                  Don't ask support requests via chat/PM. Please use the forum so others can benefit from the solution in the future

                  JonBJ 1 Reply Last reply
                  2
                  • Pablo J. RoginaP Pablo J. Rogina

                    @linda said in Open .exe file from Qt GUI:

                    It is similar to this code, the problem is I need to open the cmd in administrator mode then go the directory and key commands to run the test.exe,

                    As mentioned by @JonB you don't need to 'cd' to the folder where your .exe is located. Just use the proper path to it

                    JonBJ Offline
                    JonBJ Offline
                    JonB
                    wrote on last edited by
                    #10

                    As @Pablo-J.-Rogina says, you can execute by specifying full path without worrying about cd-ing to change your current directory.

                    However, if you do care about the sub-process's current directory --- e.g. if opening a file via a relative path --- you can use http://doc.qt.io/qt-5/qprocess.html#setWorkingDirectory to change the current directory for just the sub-process.

                    1 Reply Last reply
                    2
                    • JonBJ JonB

                      @linda
                      If your argument to execute() is actually any kind of literal string like you have typed here, it won't be right till you double those \s. Just saying....

                      SGaistS Offline
                      SGaistS Offline
                      SGaist
                      Lifetime Qt Champion
                      wrote on last edited by
                      #11

                      @JonB said in Open .exe file from Qt GUI:

                      @linda
                      If your argument to execute() is actually any kind of literal string like you have typed here, it won't be right till you double those \s. Just saying....

                      That's what QDir::toNativeSeparators is for.

                      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
                      2

                      • Login

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