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. Running multiple cmd.exe simultaneously using QProcess
QtWS25 Last Chance

Running multiple cmd.exe simultaneously using QProcess

Scheduled Pinned Locked Moved General and Desktop
7 Posts 2 Posters 3.3k Views
  • 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.
  • N Offline
    N Offline
    nanthiran_2005
    wrote on last edited by
    #1

    Hi all,

    I am currently trying to run a few batch files from Qt. Currently I am using QProcess to trigger cmd.exe and provide the batch file path as the argument. Since I have multiple files, is it possible to run more than one cmd.exe at the same to run different batch files in each cmd.exe?

    If yes, do I have to create multiple QProcess for each cmd.exe?

    1 Reply Last reply
    0
    • dheerendraD Offline
      dheerendraD Offline
      dheerendra
      Qt Champions 2022
      wrote on last edited by
      #2

      QProcess can launch one process. You need to create multiple instances

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

      1 Reply Last reply
      0
      • N Offline
        N Offline
        nanthiran_2005
        wrote on last edited by
        #3

        By instances you mean QProcess? Is there a way to dynamically create the QProcess?

        For example, each time a button is pressed, a new QProcess is created to run the batch file in new cmd.exe

        1 Reply Last reply
        0
        • dheerendraD Offline
          dheerendraD Offline
          dheerendra
          Qt Champions 2022
          wrote on last edited by
          #4

          Yes.
          bq. Is there a way to dynamically create the QProcess?

          What do you mean here ? Is it not as simple as this ?

          QProcess *proc = new QProcess.

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

          1 Reply Last reply
          0
          • N Offline
            N Offline
            nanthiran_2005
            wrote on last edited by
            #5

            Hi Dheerendra, thanks for the input.

            Sorry my question was not clear. What I meant is that, I want to run the process everytime the user press a button.

            @QProcess *proc = new Qprocess @

            does produce the process dynamically, but how do I delete them once the process is completed. My concern is because I m creating this Qprocess inside the slot that is connected with the button click. So won't I lose the pointer once I the program exit the slot function?

            1 Reply Last reply
            0
            • dheerendraD Offline
              dheerendraD Offline
              dheerendra
              Qt Champions 2022
              wrote on last edited by
              #6

              Are you launching all process simultaneously ? Or are u running them one at a time ? Some how you need keep reference to all qprocess variable, connect with finished signal and delete qprocess pointer variable. Hope this helps.

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

              1 Reply Last reply
              0
              • N Offline
                N Offline
                nanthiran_2005
                wrote on last edited by
                #7

                Hi Dheerendra, thanks for the input. Yes I got the rough idea now.
                Referring to your question, I may run more than one process simultaneously.

                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