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. How to run .exe file from absolute path with button click
Qt 6.11 is out! See what's new in the release blog

How to run .exe file from absolute path with button click

Scheduled Pinned Locked Moved General and Desktop
21 Posts 4 Posters 10.9k 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.
  • M Offline
    M Offline
    msue
    wrote on last edited by
    #6

    This should work if Patcher.exe is located parallel to the program you are running,

    But it may become wrong if you change the current directory during the run of your program.

    1 Reply Last reply
    0
    • P Offline
      P Offline
      Phani Madhavi
      wrote on last edited by
      #7

      actually what i need to do is...
      i should install an exe on button click.The things i need to understand
      1.Where should i place that exe file in my application
      2.How to run that through code

      1 Reply Last reply
      0
      • dheerendraD Offline
        dheerendraD Offline
        dheerendra
        Moderators Qt Champions 2024 Qt Champions 2022 Qt Champions 2017
        wrote on last edited by
        #8

        Can you try something very simple now from your main.

        @ QProcess *proc = new QProcess;
        QString progName = "c:/users/madhavi/Patcher";
        proc->start(progName);
        proc->errorString()
        @
        I'm assuming that your exe is in c:/users/madhavi directory. If you are able to run this, your first step is solved.

        Now.

        @ connect(pushButton,SIGNAL(clicked()),this,SLOT(launchPatch()));

        void MyClass::LaunchPatch(){
        qDebug() << "Show the Calcualtror"<<endl;

         QProcess *proc = new QProcess;
         QString progName = "c:/users/madhavi/Patcher";
         proc->start(progName);
         proc->errorString()
         proc->errorString();
         qDebug()<< " Started the process"<<endl;
        

        }
        @

        This should solve your issue.

        Dheerendra
        @Community Service
        Certified Qt Specialist
        https://www.pthinks.com

        1 Reply Last reply
        0
        • P Offline
          P Offline
          Phani Madhavi
          wrote on last edited by
          #9

          not working...:(

          1 Reply Last reply
          0
          • dheerendraD Offline
            dheerendraD Offline
            dheerendra
            Moderators Qt Champions 2024 Qt Champions 2022 Qt Champions 2017
            wrote on last edited by
            #10

            what is not working ? What is the error you get ? If you can paste your code we can help you better.

            Dheerendra
            @Community Service
            Certified Qt Specialist
            https://www.pthinks.com

            1 Reply Last reply
            0
            • P Offline
              P Offline
              Phani Madhavi
              wrote on last edited by
              #11

              i used the same.Am not getting any error message and no output. I used startDetached also. but still am not getting any output atleast error.

              1 Reply Last reply
              0
              • dheerendraD Offline
                dheerendraD Offline
                dheerendra
                Moderators Qt Champions 2024 Qt Champions 2022 Qt Champions 2017
                wrote on last edited by
                #12

                If you can drop your code and how you are trying that will help. Can you try with some other executable to start the program ? This is just ensure that you don't have any problem starting new process from Qt.

                Dheerendra
                @Community Service
                Certified Qt Specialist
                https://www.pthinks.com

                1 Reply Last reply
                0
                • P Offline
                  P Offline
                  Phani Madhavi
                  wrote on last edited by
                  #13

                  yes thank you. the problem is with exe file. I tried another exe as u said,it is working fine. finally got solution.:)

                  1 Reply Last reply
                  0
                  • dheerendraD Offline
                    dheerendraD Offline
                    dheerendra
                    Moderators Qt Champions 2024 Qt Champions 2022 Qt Champions 2017
                    wrote on last edited by
                    #14

                    This is cool. How about moving this Question to SOLVED state by editing the subject line of your question ?

                    Dheerendra
                    @Community Service
                    Certified Qt Specialist
                    https://www.pthinks.com

                    1 Reply Last reply
                    0
                    • P Offline
                      P Offline
                      Phani Madhavi
                      wrote on last edited by
                      #15

                      actually am trying to execute 4.50MB file(exe size)..is that that problem ?

                      1 Reply Last reply
                      0
                      • P Offline
                        P Offline
                        Phani Madhavi
                        wrote on last edited by
                        #16
                        QProcess *proc = new QProcess;
                             QString progName ="C:/Patcher";
                              proc->start(progName);
                              proc->errorString();
                        
                        1 Reply Last reply
                        0
                        • dheerendraD Offline
                          dheerendraD Offline
                          dheerendra
                          Moderators Qt Champions 2024 Qt Champions 2022 Qt Champions 2017
                          wrote on last edited by
                          #17

                          4.5 MB is not a issue at all. Is it not running ? May be there is dependency with some libraries. Check it.

                          Dheerendra
                          @Community Service
                          Certified Qt Specialist
                          https://www.pthinks.com

                          1 Reply Last reply
                          0
                          • P Offline
                            P Offline
                            Phani Madhavi
                            wrote on last edited by
                            #18

                            i can run that exe directly.but not able through code...

                            1 Reply Last reply
                            0
                            • P Offline
                              P Offline
                              Phani Madhavi
                              wrote on last edited by
                              #19

                              finally got solution by using
                              QDesktopServices::openUrl(QUrl("file:///"+progName,QUrl::TolerantMode));

                              1 Reply Last reply
                              0
                              • dheerendraD Offline
                                dheerendraD Offline
                                dheerendra
                                Moderators Qt Champions 2024 Qt Champions 2022 Qt Champions 2017
                                wrote on last edited by
                                #20

                                What is the error string you get ? I suspect the issue with dependency dlls not in path. Launching 4.5 MB exe is not issue.

                                Dheerendra
                                @Community Service
                                Certified Qt Specialist
                                https://www.pthinks.com

                                1 Reply Last reply
                                0
                                • P Offline
                                  P Offline
                                  Phani Madhavi
                                  wrote on last edited by
                                  #21

                                  yes. size doesn't matter .Actually application is not giving any error or output while using QProcess.Also there is no issue with dependency dlls as am able to run exe directly(not thru code).I think Problem with QProcess when execute different kind of .exe.

                                  anyways thank you very much Dheerendra thanks for ur support...:)

                                  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