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.7k 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 Offline
    L Offline
    linda
    wrote on 15 May 2018, 16:04 last edited by
    #1

    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!

    P 1 Reply Last reply 15 May 2018, 16:19
    0
    • L linda
      15 May 2018, 16:04

      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!

      P Offline
      P Offline
      Pablo J. Rogina
      wrote on 15 May 2018, 16:19 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 16 May 2018, 03:04
      3
      • M Offline
        M Offline
        mrjj
        Lifetime Qt Champion
        wrote on 15 May 2018, 16:35 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 16 May 2018, 03:18
        5
        • P Pablo J. Rogina
          15 May 2018, 16:19

          @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 16 May 2018, 03:04 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
          • M mrjj
            15 May 2018, 16:35

            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 16 May 2018, 03:18 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.

            J P 2 Replies Last reply 16 May 2018, 05:10
            0
            • L linda
              16 May 2018, 03:18

              @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.

              J Offline
              J Offline
              jsulm
              Lifetime Qt Champion
              wrote on 16 May 2018, 05:10 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 16 May 2018, 08:28
              0
              • J jsulm
                16 May 2018, 05:10

                @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 16 May 2018, 08:28 last edited by
                #7

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

                J 1 Reply Last reply 16 May 2018, 09:55
                0
                • L linda
                  16 May 2018, 08:28

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

                  J Online
                  J Online
                  JonB
                  wrote on 16 May 2018, 09:55 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....

                  S 1 Reply Last reply 16 May 2018, 22:55
                  1
                  • L linda
                    16 May 2018, 03:18

                    @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.

                    P Offline
                    P Offline
                    Pablo J. Rogina
                    wrote on 16 May 2018, 13:39 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

                    J 1 Reply Last reply 16 May 2018, 13:52
                    2
                    • P Pablo J. Rogina
                      16 May 2018, 13:39

                      @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

                      J Online
                      J Online
                      JonB
                      wrote on 16 May 2018, 13:52 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
                      • J JonB
                        16 May 2018, 09:55

                        @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....

                        S Offline
                        S Offline
                        SGaist
                        Lifetime Qt Champion
                        wrote on 16 May 2018, 22:55 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

                        1/11

                        15 May 2018, 16:04

                        • Login

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